Solutions to Advent of Code 2017 https://adventofcode.com/2017/
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

123456789101112
  1. def execute(instructions, incrementor, position=0):
  2. while 0 <= position < len(instructions):
  3. next_position = position + instructions[position]
  4. instructions[position] += incrementor(instructions[position])
  5. position = next_position
  6. yield position
  7. with open('data/05.txt', 'r') as file:
  8. instructions = list(map(int, file.readlines()))
  9. print(f'Part one: {sum(1 for _ in execute(list(instructions), lambda x: 1))}')
  10. print(f'Part two: {sum(1 for _ in execute(list(instructions), lambda x: -1 if x >= 3 else 1))}')