codingquest
feature image

Engine diagnostics

Your supervisor has granted your request for shore leave once you complete a couple of important safety checks on the ship. The first is an engine diagnostics report.

The FTL (faster than light) engines are tricky and complicated technology, however like most engine systems, the most important reading to monitor is engine temperature. Occasional spikes or dips in the temperature are a normal part of the way the FTL works, but it is important that no spike or dip lasts too long. The normal safe operating temperature for the engine is within 1500 and 1600 degrees Kelvin.

Your task is to check the temperature log files for the previous day and determine how many seconds the 60 second rolling average was either less than 1500 or greater than 1600 degrees. The log file records the temperature once per second.

An example

The following 180 entries represent three minutes of log file data.

1504
1592
1565
1584
1577
1555
1559
1571
1532
1579
1000
1563
1532
1540
1578
1503
1587
1363
1581
1550
1548
1561
1557
1097
1517
1557
1570
1566
1503
1578
1535
1128
1577
1587
1414
1517
1560
1525
1506
1523
1192
1500
1521
1082
1519
1519
1535
1545
1580
1557
1511
1587
1530
1549
1575
1536
1587
1515
1558
1153
1530
1542
1562
1584
1572
1543
1559
1568
1544
1507
1574
1512
1501
1523
1538
1582
1600
1509
1414
1523
1591
1579
1524
1561
1591
1590
1574
1523
1600
1567
1590
1509
1594
1571
1524
1531
1591
1595
1525
1512
1133
1529
1587
1531
1554
1278
1596
1513
1577
1556
1556
1516
1531
1020
1517
1600
1518
1587
1521
1588
1517
1514
1530
1589
1568
1548
1573
1573
1589
1511
1567
1547
1563
1522
1596
1533
1372
1290
1524
1517
1500
1583
1569
1590
1564
1552
1516
1526
1536
1511
1594
1313
1536
1587
1205
1572
1507
1519
1594
1592
1070
1500
1570
1579
1559
1514
1592
1506
1585
1535
1500
1011
1547
1560
1562
1542
1561
1152
1516
1578

The above example contains 10 seconds where the 60 second rolling average is outside the permissible 1500-1600 range.

Your task

Using the 24 hour dataset provided by the input data, determine for how many seconds the 60 second rolling average was either less than 1500 or greater than 1600 degrees.

To clarify: The 60 second rolling average requirement is referring to calculating an average for each block of 60 seconds. For instance, you would start with timestamps 0 to 59, then 1 to 60, then 2 to 61, then 3 to 62, and so forth; until you have found the average for every 60 second block in the dataset.

Input data

Get your puzzle input data

What is the solution?