norvig / pytudes

Python programs, usually short, of considerable difficulty, to perfect particular skills.
MIT License
23.11k stars 2.43k forks source link

Add advent of code 2020 files #98

Open chrisdoc opened 3 years ago

chrisdoc commented 3 years ago

This PR adds advent of code 2020 files based on my users sessions to the repository to fix a FileNotFoundError when running the advent of code 2020 notebook https://github.com/norvig/pytudes/blob/master/ipynb/Advent-2020.ipynb

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-4-f1ec783705fc> in <module>
----> 1 in1: Set[int] = set(data(1, int))

<ipython-input-2-8ad9be6051d4> in data(day, parser, sep)
      1 def data(day: int, parser=str, sep='\n') -> list:
      2     "Split the day's input file into sections separated by `sep`, and apply `parser` to each."
----> 3     with open(f'data/advent2020/input{day}.txt') as f:
      4         sections = f.read().rstrip().split(sep)
      5         return list(map(parser, sections))

FileNotFoundError: [Errno 2] No such file or directory: 'data/advent2020/input1.txt'