diff --git a/day_01/python/part_2.py b/day_01/python/part_2.py new file mode 100644 index 0000000..8c26dfa --- /dev/null +++ b/day_01/python/part_2.py @@ -0,0 +1,20 @@ +increasing = 0 + +with open("../input", "r") as file: + + # parse the text file into an array of integers + data = [int(x) for x in file.read().split("\n")] + + # iterate through the data until we don't have enough data to form a group + # of 3 values + for i in range(0, len(data) - 3): + + # Collect the two values for the ranges for compare + group_1 = sum(data[i : i+3]) + group_2 = sum(data[i+1 : i+4]) + + # check the delta + if group_1 - group_2 < 0: + increasing += 1 + +print(f"Number of groups increasing: {increasing}") \ No newline at end of file