From 281258cc11c4ba42525db1646007101884dc99ad Mon Sep 17 00:00:00 2001 From: Jake Date: Mon, 6 Dec 2021 07:45:39 +0000 Subject: [PATCH] Completed day 6, task 1 --- Day-6/day6-1.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Day-6/day6-1.py diff --git a/Day-6/day6-1.py b/Day-6/day6-1.py new file mode 100644 index 0000000..7e69f13 --- /dev/null +++ b/Day-6/day6-1.py @@ -0,0 +1,21 @@ +#!/usr/bin/python3 + +# Open the file and read the one line into an array. +fish = [] +with open('/home/jake/Documents/AoC-2021/Day-6/input.txt') as inputFile: + fish = inputFile.readline().strip('\n').split(',') + fish = [ int(x) for x in fish ] + +# Loop over the array decrementing and adding fish as required for 80 days. +days = 0 +while days < 80: + for i in range(0, len(fish)): + if(fish[i] == 0): + fish[i] = 6 + fish.append(8) + else: + fish[i] = fish[i] -1 + days+=1 + +# Print the results. +print("Total fish afer " + str(days) + " days: " + str(len(fish))) \ No newline at end of file