Improved template
This commit is contained in:
parent
b0d483ea21
commit
7662154a04
0
src/aoc/__init__.py
Normal file
0
src/aoc/__init__.py
Normal file
20
src/aoc/aoc.py
Normal file
20
src/aoc/aoc.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import os
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
|
||||||
|
def _get_cookie_headers() -> dict[str, str]:
|
||||||
|
"""
|
||||||
|
original code from https://github.com/anthonywritescode/aoc2022/blob/main/support/support.py
|
||||||
|
"""
|
||||||
|
with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../.env')) as f:
|
||||||
|
contents = f.read().strip()
|
||||||
|
return {'Cookie': contents}
|
||||||
|
|
||||||
|
|
||||||
|
def get_input(year: int, day: int) -> str:
|
||||||
|
"""
|
||||||
|
original code from https://github.com/anthonywritescode/aoc2022/blob/main/support/support.py
|
||||||
|
"""
|
||||||
|
url = f'https://adventofcode.com/{year}/day/{day}/input'
|
||||||
|
req = urllib.request.Request(url, headers=_get_cookie_headers())
|
||||||
|
return urllib.request.urlopen(req).read().decode()
|
@ -6,8 +6,11 @@ from cpl_query.enumerable import Enumerable
|
|||||||
from cpl_query.extension import List
|
from cpl_query.extension import List
|
||||||
from cpl_core.pipes import *
|
from cpl_core.pipes import *
|
||||||
|
|
||||||
|
from aoc.aoc import get_input
|
||||||
|
|
||||||
# global vars
|
# global vars
|
||||||
day = 0
|
day = 0
|
||||||
|
aoc_input = get_input(2022, day)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
Loading…
Reference in New Issue
Block a user