Fix directories so order makes sense

This commit is contained in:
2022-11-30 21:05:44 +00:00
parent 81e4a1ed1a
commit af978e71b5
17 changed files with 0 additions and 0 deletions

28
2021/Day-01/day1-1.py Normal file
View File

@@ -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))

33
2021/Day-01/day1-2.py Normal file
View File

@@ -0,0 +1,33 @@
#!/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:
rawValues = []
for line in inputFile:
rawValues.append(int(line))
# Sum up numbers in 3's and add them to a new array.
values = []
for i in range(0, len(rawValues) - 2):
values.append(rawValues[i] + rawValues[i+1] + rawValues[i+2])
# 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))