re-doing 2016 in python, because I can. days 1-3
This commit is contained in:
parent
e9ee54b0d9
commit
0156ff8c8d
169
.gitignore
vendored
Normal file
169
.gitignore
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
# ---> Python
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
#poetry.lock
|
||||
|
||||
# pdm
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||
#pdm.lock
|
||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||
# in version control.
|
||||
# https://pdm.fming.dev/#use-with-ide
|
||||
.pdm.toml
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
venv_pypy/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
.idea/
|
||||
|
||||
answer_cache.json
|
||||
.session
|
||||
session.cookie
|
||||
.aoc_tiles/*
|
||||
!.aoc_tiles/tiles/
|
||||
|
||||
4
archive/inputs/input11
Normal file
4
archive/inputs/input11
Normal file
@ -0,0 +1,4 @@
|
||||
The first floor contains a strontium generator, a strontium-compatible microchip, a plutonium generator, and a plutonium-compatible microchip.
|
||||
The second floor contains a thulium generator, a ruthenium generator, a ruthenium-compatible microchip, a curium generator, and a curium-compatible microchip.
|
||||
The third floor contains a thulium-compatible microchip.
|
||||
The fourth floor contains nothing relevant.
|
||||
4
archive/inputs/test_input11
Normal file
4
archive/inputs/test_input11
Normal file
@ -0,0 +1,4 @@
|
||||
The first floor contains a hydrogen-compatible microchip and a lithium-compatible microchip.
|
||||
The second floor contains a hydrogen generator.
|
||||
The third floor contains a lithium generator.
|
||||
The fourth floor contains nothing relevant.
|
||||
64
day01.py
Normal file
64
day01.py
Normal file
@ -0,0 +1,64 @@
|
||||
from tools.aoc import AOCDay
|
||||
from tools.coordinate import Coordinate, DistanceAlgorithm
|
||||
from typing import Any
|
||||
|
||||
DIRS = [Coordinate(0, -1), Coordinate(1, 0), Coordinate(0, 1), Coordinate(-1, 0)]
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
(12, "input1_test"),
|
||||
(146, "input1"),
|
||||
],
|
||||
[
|
||||
(131, "input1"),
|
||||
],
|
||||
]
|
||||
|
||||
def parse_input(self) -> list[tuple[int, int]]:
|
||||
instructions = []
|
||||
for inst in self.getInput().split(", "):
|
||||
turn = 1 if inst[0] == "R" else -1
|
||||
dist = int(inst[1:])
|
||||
instructions.append((turn, dist))
|
||||
|
||||
return instructions
|
||||
|
||||
def part1(self) -> Any:
|
||||
instructions = self.parse_input()
|
||||
facing = 0
|
||||
cur_pos = Coordinate(0, 0)
|
||||
|
||||
for turn, dist in instructions:
|
||||
facing = (facing + turn) % 4
|
||||
cur_pos += DIRS[facing] * dist
|
||||
|
||||
return cur_pos.getDistanceTo(
|
||||
Coordinate(0, 0),
|
||||
algorithm=DistanceAlgorithm.MANHATTAN,
|
||||
includeDiagonals=False,
|
||||
)
|
||||
|
||||
def part2(self) -> Any:
|
||||
instructions = self.parse_input()
|
||||
facing = 0
|
||||
cur_pos = Coordinate(0, 0)
|
||||
seen = set()
|
||||
|
||||
for turn, dist in instructions:
|
||||
facing = (facing + turn) % 4
|
||||
for _ in range(dist):
|
||||
cur_pos += DIRS[facing]
|
||||
if cur_pos in seen:
|
||||
return cur_pos.getDistanceTo(
|
||||
Coordinate(0, 0),
|
||||
algorithm=DistanceAlgorithm.MANHATTAN,
|
||||
includeDiagonals=False,
|
||||
)
|
||||
seen.add(cur_pos)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
day = Day(2016, 1)
|
||||
day.run(verbose=True)
|
||||
49
day02.py
Normal file
49
day02.py
Normal file
@ -0,0 +1,49 @@
|
||||
from tools.aoc import AOCDay
|
||||
from tools.coordinate import Coordinate
|
||||
from tools.grid import Grid
|
||||
from typing import Any
|
||||
|
||||
DIRS = {
|
||||
"U": Coordinate(0, -1),
|
||||
"D": Coordinate(0, 1),
|
||||
"L": Coordinate(-1, 0),
|
||||
"R": Coordinate(1, 0),
|
||||
}
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
("1985", "input2_test"),
|
||||
("38961", "input2"),
|
||||
],
|
||||
[
|
||||
("5DB3", "input2_test"),
|
||||
("46C92", "input2"),
|
||||
],
|
||||
]
|
||||
|
||||
def get_code(self, keypad: Grid, pos: Coordinate) -> str:
|
||||
code = ""
|
||||
for line in self.getInput():
|
||||
for move in line:
|
||||
if keypad.get(pos + DIRS[move]):
|
||||
pos += DIRS[move]
|
||||
code += keypad.get(pos)
|
||||
|
||||
return code
|
||||
|
||||
def part1(self) -> Any:
|
||||
keypad = Grid.from_data(["123", "456", "789"], default=None)
|
||||
start = Coordinate(1, 1)
|
||||
return self.get_code(keypad, start)
|
||||
|
||||
def part2(self) -> Any:
|
||||
keypad = Grid.from_data([" 1", " 234", "56789", " ABC", " D"], default=None, translate={" ": None})
|
||||
start = Coordinate(0, 2)
|
||||
return self.get_code(keypad, start)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
day = Day(2016, 2)
|
||||
day.run(verbose=True)
|
||||
43
day03.py
Normal file
43
day03.py
Normal file
@ -0,0 +1,43 @@
|
||||
from tools.aoc import AOCDay
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
(862, "input3"),
|
||||
],
|
||||
[
|
||||
(1577, "input3"),
|
||||
],
|
||||
]
|
||||
|
||||
def part1(self) -> Any:
|
||||
ans = 0
|
||||
for triangle in self.getIntsFromInput():
|
||||
if (
|
||||
triangle[0] + triangle[1] <= triangle[2]
|
||||
or triangle[0] + triangle[2] <= triangle[1]
|
||||
or triangle[1] + triangle[2] <= triangle[0]
|
||||
):
|
||||
continue
|
||||
ans += 1
|
||||
return ans
|
||||
|
||||
def part2(self) -> Any:
|
||||
vertical = self.getIntsFromInput()
|
||||
ans = 0
|
||||
for x in range(0, len(vertical), 3):
|
||||
for i in range(3):
|
||||
if (
|
||||
vertical[x][i] + vertical[x + 1][i] > vertical[x + 2][i]
|
||||
and vertical[x][i] + vertical[x + 2][i] > vertical[x + 1][i]
|
||||
and vertical[x + 1][i] + vertical[x + 2][i] > vertical[x][i]
|
||||
):
|
||||
ans += 1
|
||||
return ans
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
day = Day(2016, 3)
|
||||
day.run(verbose=True)
|
||||
1
inputs/input1
Normal file
1
inputs/input1
Normal file
@ -0,0 +1 @@
|
||||
R4, R4, L1, R3, L5, R2, R5, R1, L4, R3, L5, R2, L3, L4, L3, R1, R5, R1, L3, L1, R3, L1, R2, R2, L2, R5, L3, L4, R4, R4, R2, L4, L1, R5, L1, L4, R4, L1, R1, L2, R5, L2, L3, R2, R1, L194, R2, L4, R49, R1, R3, L5, L4, L1, R4, R2, R1, L5, R3, L5, L4, R4, R4, L2, L3, R78, L5, R4, R191, R4, R3, R1, L2, R1, R3, L1, R3, R4, R2, L2, R1, R4, L5, R2, L2, L4, L2, R1, R2, L3, R5, R2, L3, L3, R3, L1, L1, R5, L4, L4, L2, R5, R1, R4, L3, L5, L4, R5, L4, R5, R4, L3, L2, L5, R4, R3, L3, R1, L5, R5, R1, L3, R2, L5, R5, L3, R1, R4, L5, R4, R2, R3, L4, L5, R3, R4, L5, L5, R4, L4, L4, R1, R5, R3, L1, L4, L3, L4, R1, L5, L1, R2, R2, R4, R4, L5, R4, R1, L1, L1, L3, L5, L2, R4, L3, L5, L4, L1, R3
|
||||
1
inputs/input1_test
Normal file
1
inputs/input1_test
Normal file
@ -0,0 +1 @@
|
||||
R5, L5, R5, R3
|
||||
5
inputs/input2
Normal file
5
inputs/input2
Normal file
@ -0,0 +1,5 @@
|
||||
LLLRLLULLDDLDUDRDDURLDDRDLRDDRUULRULLLDLUURUUUDLUUDLRUDLDUDURRLDRRRUULUURLUDRURULRLRLRRUULRUUUDRRDDRLLLDDLLUDDDLLRLLULULRRURRRLDRLDLLRURDULLDULRUURLRUDRURLRRDLLDDURLDDLUDLRLUURDRDRDDUURDDLDDDRUDULDLRDRDDURDLUDDDRUDLUDLULULRUURLRUUUDDRLDULLLUDLULDUUDLDLRRLLLRLDUDRUULDLDRDLRRDLDLULUUDRRUDDDRDLRLDLRDUDRULDRDURRUULLUDURURUUDRDRLRRDRRDRDDDDLLRURULDURDLUDLUULDDLLLDULUUUULDUDRDURLURDLDDLDDUULRLUUDLDRUDRURURRDDLURURDRLRLUUUURLLRR
|
||||
UUUUURRRURLLRRDRLLDUUUUDDDRLRRDRUULDUURURDRLLRRRDRLLUDURUDLDURURRLUDLLLDRDUDRDRLDRUDUDDUULLUULLDUDUDDRDUUUDLULUDUULLUUULURRUDUULDUDDRDURRLDDURLRDLULDDRUDUDRDULLRLRLLUUDDURLUUDLRUUDDLLRUURDUDLLDRURLDURDLRDUUDLRLLRLRURRUDRRLRDRURRRUULLUDLDURDLDDDUUDRUUUDULLLRDRRDRLURDDRUUUDRRUUDLUDDDRRRRRLRLDLLDDLRDURRURLLLULURULLULRLLDDLDRLDULLDLDDDRLUDDDUDUDRRLRDLLDULULRLRURDLUDDLRUDRLUURRURDURDRRDRULUDURRLULUURDRLDLRUDLUDRURLUDUUULRRLRRRULRRRLRLRLULULDRUUDLRLLRLLLURUUDLUDLRURUDRRLDLLULUDRUDRLLLRLLDLLDUDRRURRLDLUUUURDDDUURLLRRDRUUURRRDRUDLLULDLLDLUDRRDLLDDLDURLLDLLDLLLDR
|
||||
LRDULUUUDLRUUUDURUUULLURDRURDRRDDDLRLRUULDLRRUDDLLUURLDRLLRUULLUDLUDUDRDRDLUUDULLLLRDDUDRRRURLRDDLRLDRLULLLRUUULURDDLLLLRURUUDDDLDUDDDDLLLURLUUUURLRUDRRLLLUUULRDUURDLRDDDUDLLRDULURURUULUDLLRRURDLUULUUDULLUDUUDURLRULRLLDLUULLRRUDDULRULDURRLRRLULLLRRDLLDDLDUDDDUDLRUURUDUUUDDLRRDLRUDRLLRDRDLURRLUDUULDRRUDRRUDLLLLRURRRRRUULULLLRDRDUDRDDURDLDDUURRURLDRRUDLRLLRRURULUUDDDLLLRDRLULLDLDDULDLUUDRURULLDLLLLDRLRRLURLRULRDLLULUDRDR
|
||||
RURRRUDLURRURLURDDRULLDRDRDRRULRRDLDDLDUUURUULLRRDRLDRRDRULLURRRULLLDULDDDDLULRUULRURUDURDUDRLRULLLRDURDDUDDRDLURRURUURDLDDDDDURURRURLLLDDLDRRDUDDLLLDRRLDDUUULDLLDRUURUDDRRLDUULRRDDUDRUULRLDLRLRUURLLDRDLDRLURULDLULDRULURLLRRLLDDDURLRUURUULULRLLLULUDULUUULDRURUDDDUUDDRDUDUDRDLLLRDULRLDLRRDRRLRDLDDULULRLRUUDDUDRRLUDRDUUUDRLLLRRLRUDRRLRUUDDLDURLDRRRUDRRDUDDLRDDLULLDLURLUUDLUDLUDLDRRLRRRULDRLRDUURLUULRDURUDUUDDURDDLRRRLUUUDURULRURLDRURULDDUDDLUDLDLURDDRRDDUDUUURLDLRDDLDULDULDDDLDRDDLUURDULLUDRRRULRLDDLRDRLRURLULLLDULLUUDURLDDULRRDDUULDRLDLULRRDULUDUUURUURDDDRULRLRDLRRURR
|
||||
UDDDRLDRDULDRLRDUDDLDLLDDLUUURDDDLUDRDUDLDURLUURUDUULUUULDUURLULLRLUDLLURUUUULRLRLLLRRLULLDRUULURRLLUDUDURULLLRRRRLRUULLRDRDRRDDLUDRRUULUDRUULRDLRDRRLRRDRRRLULRULUURRRULLRRRURUDUURRLLDDDUDDULUULRURUDUDUDRLDLUULUDDLLLLDRLLRLDULLLRLLDLUUDURDLLRURUUDDDDLLUDDRLUUDUDRDRLLURURLURRDLDDDULUURURURRLUUDUDLDLDDULLURUDLRLDLRLDLDUDULURDUDRLURRRULLDDDRDRURDDLDLULUDRUULDLULRDUUURLULDRRULLUDLDRLRDDUDURRRURRLRDUULURUUDLULDLRUUULUDRDRRUDUDULLDDRLRDLURDLRLUURDRUDRDRUDLULRUDDRDLLLRLURRURRLDDDUDDLRDRRRULLUUDULURDLDRDDDLDURRLRRDLLDDLULULRRDUDUUDUULRDRRDURDDDDUUDDLUDDUULDRDDULLUUUURRRUUURRULDRRDURRLULLDU
|
||||
4
inputs/input2_test
Normal file
4
inputs/input2_test
Normal file
@ -0,0 +1,4 @@
|
||||
ULL
|
||||
RRDDD
|
||||
LURDL
|
||||
UUUUD
|
||||
1635
inputs/input3
Normal file
1635
inputs/input3
Normal file
File diff suppressed because it is too large
Load Diff
41
main.py
Normal file
41
main.py
Normal file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import tools.aoc
|
||||
import argparse
|
||||
import importlib
|
||||
import os
|
||||
|
||||
YEAR = 2024
|
||||
TIMEIT_NUMBER = 50
|
||||
|
||||
argument_parser = argparse.ArgumentParser()
|
||||
argument_parser.add_argument("-d", "--day", help="specify day to process; leave empty for ALL days", type=int)
|
||||
argument_parser.add_argument("-p", "--part", help="run only part x", choices=[1, 2], type=int)
|
||||
argument_parser.add_argument("--timeit", help="measure execution time", action="store_true", default=False)
|
||||
argument_parser.add_argument(
|
||||
"--timeit-number",
|
||||
help="build average time over this many executions",
|
||||
type=int,
|
||||
default=TIMEIT_NUMBER
|
||||
)
|
||||
argument_parser.add_argument("-v", "--verbose", help="show test case outputs", action="store_true", default=False)
|
||||
flags = argument_parser.parse_args()
|
||||
|
||||
import_day = ""
|
||||
if flags.day:
|
||||
import_day = "%02d" % flags.day
|
||||
|
||||
imported = []
|
||||
for _, _, files in os.walk(tools.aoc.BASE_PATH):
|
||||
for f in files:
|
||||
if f.startswith('day' + import_day) and f.endswith('.py'):
|
||||
lib_name = f[:-3]
|
||||
globals()[lib_name] = importlib.import_module(lib_name)
|
||||
imported.append(lib_name)
|
||||
|
||||
break
|
||||
|
||||
for lib in sorted(imported):
|
||||
day = int(lib[-2:])
|
||||
day_class = getattr(globals()[lib], "Day")(YEAR, day)
|
||||
day_class.run(flags.part if flags.part else 3, flags.verbose, flags.timeit, flags.timeit_number)
|
||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
shs-tools ~= 0.4
|
||||
pre-commit
|
||||
24
skel_day.py
Normal file
24
skel_day.py
Normal file
@ -0,0 +1,24 @@
|
||||
from tools.aoc import AOCDay
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
(None, "input%DAY%"),
|
||||
],
|
||||
[
|
||||
(None, "input%DAY%"),
|
||||
]
|
||||
]
|
||||
|
||||
def part1(self) -> Any:
|
||||
return ""
|
||||
|
||||
def part2(self) -> Any:
|
||||
return ""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
day = Day(%YEAR%, %DAY%)
|
||||
day.run(verbose=True)
|
||||
58
start_day.py
Normal file
58
start_day.py
Normal file
@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
from argparse import ArgumentParser
|
||||
from datetime import datetime
|
||||
from os.path import exists
|
||||
from platform import system
|
||||
from subprocess import call
|
||||
from time import sleep
|
||||
from tools.tools import human_readable_time_from_delta
|
||||
import webbrowser
|
||||
|
||||
|
||||
YEAR = 2016
|
||||
CHARMS = {
|
||||
'Linux': '/usr/local/bin/charm',
|
||||
'Windows': r'C:\Users\pennywise\AppData\Local\JetBrains\Toolbox\scripts\pycharm.cmd'
|
||||
}
|
||||
|
||||
arg_parser = ArgumentParser()
|
||||
arg_parser.add_argument("-d", "--day", help="start a specific day (default: today)", type=int)
|
||||
args = arg_parser.parse_args()
|
||||
|
||||
DAY = args.day or datetime.now().day
|
||||
|
||||
if YEAR < 2015 or not 1 <= DAY <= 25:
|
||||
print("Invalid year or day for year: %d, day: %d" % (YEAR, DAY))
|
||||
exit()
|
||||
|
||||
day_file = "day%02d.py" % DAY
|
||||
if exists(day_file):
|
||||
print(day_file, "already exists. Use that one!")
|
||||
exit()
|
||||
|
||||
start = datetime(YEAR, 12, DAY, 6, 0, 0)
|
||||
now = datetime.now()
|
||||
if start > now:
|
||||
time_wait = start - now
|
||||
if time_wait.days > 0:
|
||||
print("Do you really want to wait %d days?" % time_wait.days)
|
||||
exit()
|
||||
|
||||
while time_wait.seconds > 0:
|
||||
print("Day %d starts in %s.\r" % (DAY, human_readable_time_from_delta(time_wait)))
|
||||
if time_wait.seconds > 70:
|
||||
wait = min(1, time_wait.seconds // 3600) * 3600 + min(1, time_wait.seconds // 60) * 60
|
||||
sleep(wait)
|
||||
else:
|
||||
sleep(1)
|
||||
time_wait = start - datetime.now()
|
||||
|
||||
|
||||
with open("skel_day.py", "r") as IN:
|
||||
with open(day_file, "w") as OUT:
|
||||
while in_line := IN.readline():
|
||||
OUT.write(in_line.replace("%YEAR%", str(YEAR)).replace("%DAY%", str(DAY)))
|
||||
|
||||
call(["git", "add", day_file])
|
||||
webbrowser.open("https://adventofcode.com/%d/day/%d" % (YEAR, DAY))
|
||||
call([CHARMS[system()], day_file])
|
||||
Loading…
Reference in New Issue
Block a user