From aaafcf842b7b2d77a84e87c267de5d5ac27462a2 Mon Sep 17 00:00:00 2001 From: Jake Date: Wed, 1 Dec 2021 07:38:59 +0000 Subject: [PATCH] Completed day 1, task 1 --- Day-1/day1-1.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Day-1/day1-1.py diff --git a/Day-1/day1-1.py b/Day-1/day1-1.py new file mode 100644 index 0000000..7ac6a64 --- /dev/null +++ b/Day-1/day1-1.py @@ -0,0 +1,28 @@ +#!/usr/bin/python3 + +# Variables to hold our totals. +increased = 0 +decreased = 0 + +# Read in the input file and make it an array. +with open('input.txt', 'r') as inputFile: + values = [] + for line in inputFile: + values.append(int(line)) + +# Loop through the array skipping the first value. +for v in range(0, len(values)): + if(v == 0): + continue + + # Check each value against the one before it. + if(values[v - 1] < values[v]): + increased+=1 + elif(values[v - 1] > values[v]): + decreased+=1 + else: + pass + +# Print the output. +print("Decreased: " + str(decreased)) +print("Increased: " + str(increased)) \ No newline at end of file