advent_of_code/2021_01/submarine_depth_iter.py
2021-12-01 23:15:59 +01:00

38 lines
558 B
Python

MEASUREMENTS = (
199,
200,
208,
210,
200,
207,
240,
269,
260,
263,
)
def _calc_measurement(x: int, y: int):
if x - y > 0:
return f'{x}: increased'
return f'{x}: decreased'
def main():
it_a = iter(MEASUREMENTS)
it_b = iter(MEASUREMENTS)
print(
f'{next(it_a)}: N/A - no previous measurement\n' +
'\n'.join(
map(
_calc_measurement,
it_a,
it_b
)
)
)
if __name__ == '__main__':
main()