advent_of_code_2021

My attempts to work through the 2021 Advent of Code problems.
git clone https://git.eamoncaddigan.net/advent_of_code_2021.git
Log | Files | Refs | README | LICENSE

commit 9f04e689b1bea48107ab1139ed55a92981a1e28b
parent e9f1d4a03c4acec1ef6800a196e01348f3f0ff0e
Author: Eamon Caddigan <eamon.caddigan@gmail.com>
Date:   Wed,  1 Dec 2021 19:03:23 -0500

Adding a (not implemented) argument to `get_puzzle_input` in case future puzzles need binary data

Diffstat:
Mutils.py | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/utils.py b/utils.py @@ -3,11 +3,14 @@ import os.path import requests -def get_puzzle_input(day_number): +def get_puzzle_input(day_number, binary=False): """Downloads and returns the input data for the puzzle on a given day. Note: requires a 'session' cookie string to be stored in '~/.config/advent_of_code/session' and will raise an error if it's not - found.""" + found. Set `binary` to `True` to receive binary (and not text) data.""" + if binary: + raise RuntimeError('binary file output not supported yet') + with open(os.path.expanduser('~/.config/advent_of_code/session'), 'rt') \ as f_in: session = f_in.readline().strip()