💾 Archived View for cjc.im › 2017 › 12 › 01 › Advent-of-Code-Day-1 › index.gmi captured on 2022-07-16 at 13:44:06. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-03-01)
-=-=-=-=-=-=-
Dec 01, 2017
It's that time of year again!!!!!!
http://adventofcode.com/2017/day/1[1] for details of the puzzle.
1: http://adventofcode.com/2017/day/1
Here is my very quick and dirty python to solve day one part one.
total = 0 for index in range(0, len(test)): x = int(test[index], 10) if index + 1 >= len(test): y = int(test[0]) else: y = int(test[index+1], 10) if x == y: total += x print(total)
Not attempting to do any level of engineering here, just solve these easy levels as they are pretty simple.
The 2nd level was a slight change that required some minor changes
test2 = test + test dist = int(len(test)/2) total = 0 for index in range(0, len(test)): x = int(test2[index], 10) y = int(test2[index + dist]) if x == y: total += x print(total)
Done. See you tomorrow