day01
This commit is contained in:
parent
a7a383dca8
commit
969110d033
26
day01.py
Normal file
26
day01.py
Normal file
@ -0,0 +1,26 @@
|
||||
from tools.aoc import AOCDay
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
(24000, "input1_test"),
|
||||
(70509, "input1")
|
||||
],
|
||||
[
|
||||
(45000, "input1_test"),
|
||||
(208567, "input1")
|
||||
]
|
||||
]
|
||||
|
||||
def part1(self) -> Any:
|
||||
return max(sum(elf) for elf in self.getMultiLineInputAsArray(int))
|
||||
|
||||
def part2(self) -> Any:
|
||||
return sum(sorted(sum(elf) for elf in self.getMultiLineInputAsArray(int))[-3:])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
day = Day(2022, 1)
|
||||
day.run(verbose=True)
|
||||
2237
inputs/input1
Normal file
2237
inputs/input1
Normal file
File diff suppressed because it is too large
Load Diff
14
inputs/input1_test
Normal file
14
inputs/input1_test
Normal file
@ -0,0 +1,14 @@
|
||||
1000
|
||||
2000
|
||||
3000
|
||||
|
||||
4000
|
||||
|
||||
5000
|
||||
6000
|
||||
|
||||
7000
|
||||
8000
|
||||
9000
|
||||
|
||||
10000
|
||||
@ -5,10 +5,10 @@ from typing import Any
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
(None, "input%DAY%")
|
||||
(None, "input%DAY%"),
|
||||
],
|
||||
[
|
||||
(None, "input%DAY%")
|
||||
(None, "input%DAY%"),
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
20
start_day.py
20
start_day.py
@ -24,16 +24,6 @@ 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()
|
||||
|
||||
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)))
|
||||
|
||||
start = datetime(YEAR, 12, DAY, 6, 0, 0)
|
||||
now = datetime.now()
|
||||
if start > now:
|
||||
@ -46,6 +36,16 @@ if start > now:
|
||||
print("Day starts in %02ds.\r" % x)
|
||||
sleep(1)
|
||||
|
||||
day_file = "day%02d.py" % DAY
|
||||
if exists(day_file):
|
||||
print(day_file, "already exists. Use that one!")
|
||||
exit()
|
||||
|
||||
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([CHARMS[system()], day_file])
|
||||
webbrowser.open("https://adventofcode.com/%d/day/%d" % (YEAR, DAY))
|
||||
call(["git", "add", day_file])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user