Skip to content

Instantly share code, notes, and snippets.

@kstrauser
Created December 1, 2018 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kstrauser/02d82351d4901824caba3107d9ff70ed to your computer and use it in GitHub Desktop.
Save kstrauser/02d82351d4901824caba3107d9ff70ed to your computer and use it in GitHub Desktop.
My solution for the December 1, 2018 Advent of Code question #2
#!/usr/bin/env python
import itertools
import pathlib
value = 0
seen = set()
for line in itertools.cycle(
int(line) for line in pathlib.Path("input/1.txt").read_text().splitlines()
):
value += line
if value in seen:
print(f"Saw {value} twice.")
break
seen.add(value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment