Initial commit: AoC solutions 2023-2025

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Samuel Enocsson
2025-12-02 10:39:09 +01:00
commit 549f0c4382
90 changed files with 17360 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
# Python
__pycache__/
*.py[cod]
.venv/
venv/
.env
# IDE
.idea/
.vscode/
*.swp
# OS
.DS_Store
# uv
uv.lock
+1000
View File
File diff suppressed because it is too large Load Diff
+1000
View File
File diff suppressed because it is too large Load Diff
+63
View File
@@ -0,0 +1,63 @@
import re;
numbers = [
"zero",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine"
]
def main():
totalvalue = 0
with open("1-input.txt", 'r') as file:
for line in file:
line = line.strip()
word = ''
digits = []
for s in line:
nr = get_number(s)
if nr == None:
word += s
nr = get_number(word)
if nr != None:
digits.append(nr)
break
word = ''
for i in range(len(line) - 1, -1, -1):
s = line[i]
nr = get_number(s)
if nr == None:
word = s + word
nr = get_number(word)
if nr != None:
digits.append(nr)
break
if len(digits) == 2: totalvalue += digits[0] * 10 + digits[1]
print(totalvalue)
def get_number(s):
if s.isnumeric():
return int(s)
for n in numbers:
if s.count(n) > 0:
return numbers.index(n)
return None
def isDigit(s: str, a: list):
digits = re.findall("\d", s)
if (digits.__len__() > 0):
return a.append
for n in numbers:
if (s.contains(n["s"])):
return n["n"]
return a;
if __name__ == "__main__":
main()
+140
View File
@@ -0,0 +1,140 @@
F-L----F7-7.F-7JJ.F--L-.F|F77.L|7.FLF-7.JJ--7FF-F-F7F7.7-F-7.L.FL7F|7--777.FJ-|7J-F-J-77-FF-F-7.JF77.L.JFL.L-|-FF7-77FL--F77.7-|77F7|7FF7-7-
J|F7.LL|.F7.FL|J-77--JJ7L|-|-F-7L7-|LJ|F|JL|L-JJ|L|--7FF77.|-L7|LFLF-7FL--LL.FLJL-JFF-F7.-LJLF|J-LJ|FJ.|7-7L-JF|.J.LF7|L7.LF-|7F7-|-7-J7|7.|
FF7J.7L|-7|FF7|L7|L|.LF7-JFLJJ.J7JJFJ-7.L-LLJJ|LJ7LL|.JLL---.LFJ7L-LJL-|JJ-|-F.LJ7|FLF-J.L7.FJ||F||L|L7--F..FLF7-L7|LLJ7L7.-7||||J|FJ.LLJ7F-
FJ.LF-7-FJLJ-|7-7J777..|-FJ7.FJ.|.F|LFL-L7L|..--L|7.F-7-L|..FF|JF|7J.|7|FF-|.LF7LL77.J.LJL|7LF-77.|FFJ|7FLJF|-F7..FJF7L7.FJF7LJ||--|JJLLJF.J
|FF7LFL7LJJL|.|.||L77--|7F---L.F|77JFL7.F|7FL7.F7LJ-7-JJLJ.--JLJFJ77F|7F|-.|L-LJ7-LJ7FJ7.|J|-F-J|FL7|-L-J7|-.L7JJ-L||L-|7J.LF7FLL-|||.FF-7J.
FFJ-7LL7JF-.LL|-L--||.F|FL7J..LLJ|J.J.FF7L||JFJLL.J-J7LF7J77.7.||.F-FJ-|J.77.F-LLJJ|L-7|L---7JFL-7FJ-7FFL|7FLFJ|L|F-JL|.|.|-J7-LL-FL-.FFLJJ7
LL7.L--|7LJ7J.7|FL7.F77FF..-|7-L-|F7.L7JLFJ|LL|.LF-FLL7LLL-|7|F7F-7-J.FL-F|-J77-|.F-.L-J.L|||F|JLJJ7FJF7|J|7FL77FL|.|L|J7FF-L--..L|.F-77JL7-
|LF-7L.|FLLJ.LJ7-7FJL--FJ7L.7J.|JL|J-7|F7-.J7L|L-L77J|L7..FJF7LF77|J-.L--.-7L-F7F-J.F-|J|.FL7-7-F|JF.FL|---J-FFJF|.F|7F-FF.FL7--..J.|LL---JJ
|.--7.F|F7.J-LLJJLFJ.|.|-||-|LF77-7|FF||||7.JFFJF-J7|.F7FFF7||FJ|7|.|.|.L-FJFLJL|7|F|.L7.L|L|.-.LJF|F7|..FFJ-LJF.JJ7L||LLJ7---JLL-|7LFF7-7.|
F-LJJF-FJ-|..||L.JJ|-77|LF-F77F-7|LF7-L--7-|.FJ-JJ-JFF|L--J||LJFJJ-F-FJ.|FJFJJ..L7.|.F7J--L.|7.JJ.--7L7JF7L|J|FF7.LF7LJ-|||.|L-JL7-7-FJ-FJ-7
FJ||FF7-J|L|-LF7LF7J7F7F7|FJ|FJFJJ--J|L|7LL|7LL-77J7FFL7F-7LJF7L7J.7-|.-F7|||-F|-FFF-J|J.F|7F-7.|FL-J-LJ-|7LFF7||7-|L7-F77-LJ|.FFLJL-|L|L|..
J.LJ-|LL-77F7.||-J|F-JL|L7L7|L7|.|-|FF-F..LJ|.LL|-F7-F7LJFJF7|L-JLFF.L-|JF7F7F7JJF7L7FJF7JLF|FJ777.|.7.|F77-FJLJ|F7L7|.||..JJFLJ77F7|F-J.|-7
|77JFL77L|-J|--|7F-||LFL7|F||-|L77--F7J|7L.F-|J|LFJ|||L7JL7||L7F7F7J|..L||LJL-7F-JL7|L7||7-FJL-777.F.F-7||F7L7F-J|||||FJL777FL-L---.JJ|LJ.L|
7JL--7.|.|77L7.F7-FF7FF-JL7||-L7|F7.||.77L|--7FF7L7L7|FJ77LJ|FJ|LJ|7|FF7-L-7F-JL--7||FJ||F7|F--JF--77L7LJ||L7|L7FJL-J||F-J||J.77F|.|-|7FL.FF
.F7F7F7JF.F--7-L7.F||7L--7LJL--J|||-||FF7F7JFF7||.L7||L-77F-JL-JF7|F7FJ|7|FJ|F7F--JLJL7||||||F7||F-JF7|F-JL7|L7||F---J||||7|-J-L-|7L7F-|77F-
FL||-L7F|7JL7J77F7FJL7F-7L-7F---J|L7||FJ|||7FJ|||7-|||F7L7L-7F-7|LJ||L7L-7L7|||L--7F--J||||||||-|L-7|||L-7.||FJ||L--7FJL-7L7LL|J.|J-LJ||LJJ.
|JLF-.LL|-J|L7FF||L7FJ|FJJFJL7FF7|FJ||L7||L7L7||L-7||||L-J|FJL7LJ|L|L7|F-J|||||F7.|L7F7|||LJLJL7L7FJ||L7FJFJ|L7LJF--J|F--J7J..F7FL.|-LFFJ|F7
.|7||.L|J.FL7FF-JL7|L7||F7L7FJFJ|||F||.|||FJFJ|L-7||||L7F7FJF7L-7F7L7LJ|F7FJLJ|||FJFJ||||L-7F--JFJL7|L7|L7L7|FL7FJ-F7||-LF7JFFJL7LJ77F7-.||7
L7FFL7-|-J--7-L--7|L7||||L-J|FJFJ|L7||FJLJL7L7L7FJLJ||FJ||L7|L7FJ|||L-7|||L--7|||L7|FJ|||F7||F-7L-7LJFJ|FJFJL-7||F7|||L-7||77L7JJL|-FJJ-77JL
L7LLJJ.JFLL7JFF--JL7|LJ|L--7||FJFJFJ||L7F--J|L7|L--7|||FJ|FJL7||FJ|F7-||||FF-J|||L||L7||||||||FJ|FJF-JFJL7L--7LJLJLJLJF-J||LFFJ.7JL.|L|.|F.|
F|.|--F7|-FJ7L|F--7LJF-J.F7|LJL7L7|FJL-J|F7FF7||7F-J|||L7LJF-JLJL7||L7|LJL7L-7LJL-JL-J|||||||||F7L7L-7|F7L7F7|F------7L--JL-7|--7F|FJ.|FJ|7.
7F-7-JLJLF-7LLLJF-JF7L7-FJ|L7F-JFJLJF---J|L7|||L7L-7LJL7|F7L7-F--J|L7||F--JJ|L----7F--J|||||LJLJ|LL7FJLJL7||||L77F7F7L------JJ7LL777|-F7||7F
|FJJ..LL-7|||FF7L-7|L7L7L7|||L-7L7F7|7F7.L7||LJFJF7|F--JLJL7L7L--7|FJ||L7F-77F7.F7|L-7FJLJLJF---JF7||F7F-J|||L7|FJLJL7F7F-7||-F7L--77LJLJJ7|
LL.F-|7JJ.J-FFJL-7LJFL7|FJ|FJF-J.|||L7|L7FJ||F-JFJLJL7F7F7F|FJF7FJ|L7LJFJL7|FJL7|||F-JL---7FJ-F7-||||||L-7|||FJLJF--7LJLJFJF7FJL77FLL-JLL7|L
|FJ|LJ|L-F-LFL7F7L-7F7||L7||FJJF7LJL7||FJL7||L-7L--7FJ||||FJL7|||FJL|F-JF-J|L-7LJ||L7F7F7|||F7|L7|||LJ|F7|||||F--JF7L----JFJ||F-J-|7JJ|-|JJJ
JJ-J-JJF-7|L|-LJ|F7LJLJL-JLJ|F7|L7F7|LJ|F-J||F-JF7F||.|||||F-J||||F-JL-7L-7L-7L7FJ|FJ|LJ|FJ||||FJ||L7FJ|||||S|L---J|F7F7F7|FJ||F7JJF-L|-|L77
JLF-7..|7||F|JF-J||F7F7F-7F7LJ|L7||||F-JL-7|||F7||FJ|FJ||LJ|F7||||L7F-7|F7|F7|FJ|FJL7L-7LJFJ|||L7|L-J|FJ||||LJF----J|||LJ||L7||||FF777|F7FFJ
FL|F7-|FJ-L-L.L--JLJ||LJ|LJL7FJFJ||LJL7JF7|LJ|||||L7||FJL-7|||||||FJL7LJ||LJ||L7|L7FJF7L-7|FJLJFJL--7|L7||||F-J7F--7|||F-JL7||LJ|FJ|.|7JL-JJ
|.-|J.L-J|FJ|7|LF--7LJF-----JL7L7|L-7FJFJ|L-7||||L-JLJL-7FJLJLJLJLJF-JF7|L7FJL7||FJL7||FFJ|L-7FJF7LFJL7||||||F--JF-J|||L7F7|LJF-J|FJF77J||..
F-LL--.FL-7.|J-FL-7L--JF-----7L-J|F-JL7|FJF-J|||L--7F---JL--7F----7|F7||L7|L-7|||L-7LJL7L7|F7|L7||FJF7||||||||F--JF7||L7LJ||F7L7FJ|FJL7.J7FF
777F7F-J-|.LF7--JFJF7F-JLF--7L-7FJL-7FJ|L7L7FJ||-F-JL7LF7F7JLJF7JFJLJ||L7||F7|LJL-7L--7L7||||L7LJLJFJLJ|||LJLJ|F7-||||FJF-J||L-JL7||F-J7FLJ.
J--L7F.J.7FL||FFFL7|||F-7L-7L--JL--7|L7|FJFJ|FJL7L--7L7|LJ|F7FJL7L7F-JL7LJ|||L-7F-JF-7L7||LJ|LL7F--J||FJLJF7F-J|L7||||L7L--J|F--7|LJL--77.L7
F--LLLL7LL7LF7F7F7LJLJL7L-7L----7F-J|FJ||FJFJ|F-JF7-L7|L7FJ|||F-JFJ|F-7L7FJ||F7||F7L7||||L-7|F7||F7F7FJF--JLJ-FJFJ||||FJF---JL7FJ|F-7F7L-77J
J|-7.|J|FJ-FJLJ|||F--7LL-7L-----JL--JL7|LJFJ7|L-7||F7||FJL7|||L7FJFJL7L7||FJ|||||||FJ|FJL7FJ||LJ||||LJFJLF-7F7L7|L|LJLJFJF--7FJL-J|-LJ|F-J77
LL-F-JF|L.FL-7FJ||L7FJF7FJF--7F7F--7F-JL7FJF7L7FJ||||||L7FJ|||FJ|FJF7L7|||L7|||||||L7||F-JL7|L7FJ|||F-JF7|FJ||J||FJF7F7L-JF7LJF7F7L--7LJFJLJ
7JLJL-FJJ|7F7||FJ|FJ|FJ|L-JF-J|LJF7||F-7|L7|L7|L-J|||||FJ|FJLJ|FJL7|L7|||L7|||LJ||L7|||L7F7|L7|L-J|||F7|LJL-JL7|LJFJLJL-7FJL7FJ|||F-7L777-J.
|..L7LJ.LF-JLJ|L7|L7|L7|F7FL--J-FJLJLJ7||FJL7|L--7LJ||LJJ||F--JL-7|L7LJ|L7|||L7FJ|FJ|LJL||LJFJ|F--J|||||F-----J|F-JF7FF7|L-7LJFLJ|L7L7L77-7J
7.77||.F||F7F7L-J|FJL7||||F7F--7L-----7||L7FJ|F-7|F7|L--7||L7F7F7|L7|F-JFJ||L7|L7|L7L-7FJ|.FJFJL7F7|||LJL7F--7FJL-7||FJ||F7L----7|FJ-L7|JFF.
|..FF7.F-LJLJL--7LJF-J||||||L-7|F7F---JLJFJ|FJ|.LJ|LJF7FJLJJLJ|||L7||L-7L7||-LJ|||FJF7|L7L7|FJF-J||||L7F7LJF7LJF-7LJLJFJ||L-7F7FJLJ|FFLJFJ..
|.F7L|-J-|LF----JF7L-7||||||F7||||L-----7L-JL7L-7-L7FJ|L---7F-J|L7||L7FJFJ|L-7F-J|L7|||FJFJ||.|F7|||L-J||F-J|F7L7|F-7FJ|LJF7LJLJJLL7F-7LJ-FJ
JJ.|7L7LFJ-L-----JL-7||||LJ||||LJL---7F7|F---JF-JF7|L7|F7F7|L-7|FJ|L-J|FJFJF7||F7L7||||L7|-LJFJ|LJ||F--JLJF7LJ|FJ||-LJF7F7|L--7F7-7L7J-7L.7.
||F||-J7LL7|JF------JLJLJF7LJLJF7F--7LJLJ|F7F7|F-JLJFJ||||LJF-J|L7L-7JLJ.L7|||||L7|||||FJL--7L-JF-J|L-----JL-7||7|L---JLJLJF--J||.L7|JF|FF-J
.-J-F.L|7FJ-FL-7F--7F---7|L-7F-JLJF-JF7F7LJ||||L7F-7|L|||L-7L-7|L|F7L--7F7||||||FJ|||||L7F7FJF-7L-7|F------7FJ|L7L---------JF7FJL7|LLJF.JJ|.
FLL7|FFL77JJF-7LJF-J|F--J|F7||F--7L-7|LJ|F7LJLJLLJFJL7LJL7FJ|FJ|FJ||F-7LJ|||||||L7|||||FJ||L7L7L--J|L7F7F7-LJ|L-JF-7F7F-----J||F-J7.|.|.|..F
FJ|L--J7LFJ-L7|F7L--JL-7FJ|LJ|L-7L--JL-7LJL7F-77F7|F-JF7J||7FJFJ|FJ|L7|F-J||||||FJ||||||FJL7|-L---7|FJ|LJL-7|F7F7|FJ|LJF-----J|L---7FL7F-F7|
|-JJJ7|7F|FF-JLJL------JL7L7FJF7L---7F7|F--J|FJFJLJL--J|FJL7L7|J|||L7||L-7||LJLJL-JLJ||||7JLJF7F-7LJ|FJF7F7L-JLJLJL-JF-J.F7F7.|F---J7.LJ7|FL
L7|.LLL7-||L7F7F---------J.LJFJL--7FJ||||F7FJL7L7F-7F7FJL7FJ|LJFJL7FJ||F7||L--7F--7F-J||L7F--JLJFJF7||FJLJL7F7F7F-7F7L---JLJL-JL--7|F77|--.J
.FJF7JLJ.FF-J||L7F-7F7F7F7F7FJF--7|L-JLJLJLJF7L7|L7||||F-JL---7|F7|L7|LJLJ|F--JL-7LJF7||FJL-7F-7|FJ|LJL---7LJLJLJL||L7F--7F7F-7F7FJFJL7|J|7.
|J-L-77.F|L-7||FJL7|||||||||L-J|FJL-7F-7F7F7||FJL-JLJ|||F7F7F-J||||FJL-7F-J|F7LF-JF7|||LJF--J|-||L7||F----JF-----7||7|L-7||||J|||L-JF-J7F|FL
|.F7LJ|7L||LLJLJF-JLJLJLJLJL7LF7L--7|L7LJ|||||L-----7||LJ|||L-7LJ||L-7FJL-7LJL7L7FJ||LJF-JF--JFJ|FJL7L-----JF----JLJFJF7||||L7LJ|F-7L--7-L-.
.F7JJ---JL7|F---JF---------7|FJ|7F-JL-JF7LJLJ|F-7F--JLJF-J||F7|F-J|F-JL--7L7F-JFJ|FJL7FL7FJJF7L7|L-7L7F7F---J|F7F-7|L-JLJ||L7|F-JL7L7F7|J7--
LLJ-F7JL|FF-JF---JF--------JLJFJFJF7F7FJL7F-7|L7|L---7-L-7|||LJ|F7|L7F7F7L7|L-7L-JL7FJF7LJF-J|FJL--JFJ||L----7|||FJF7F--7LJ7LJ|F7FJFJ|LJLJ.L
J7|F-F--JFL--JFF-7L----------7|JL-JLJ|L7FJL7|L-JL----JF-7|||L-7||||FJ|||L7||F7|F---JL7||F-JF7LJF-7F7L-JL--7F-J|LJL-JLJF7L----7LJ|L7L-JJ-FJF.
LFF7JJ.F7FFF7F7L7L----------7||F-7.F7L-JL-7|L------7F7|FJLJ|F-JLJ||L7||L7||||LJL7F-7FJ||L--JL7FJFJ||F7F7F7LJF-JF------JL-7F--JJLL-JJL|-77-77
LL|JLF-F-7FJLJL-JF-----7F7F7LJ|L7L-JL----7LJF------J|LJL-7FJL-7F7LJFJ||FJ|||L7F-J|FJ|FJL7F7F7LJFJFJLJ||||L--JF7L-----7F-7|L---7-L7|.-.FLJLJJ
--777L7L7||F-7F--JF7JF7LJLJL-7|FJF-----7FL-7L---7F7||F-7FJL-7FJ|L7FJFJ||FJ||FJL--JL-J|F7LJ|||F7L-JF7JLJLJF---JL---7F7LJFJL-7F7|FL|7FJ7F|77|7
LLF-J|LFJLJ|FJL7F-JL7|L-7FF7||LJFJLF---JF77L-7F7LJL-JL7||F--JL7|FJL7|FJ|L7|LJF7F7F7F7LJL-7LJLJ|F7FJL-----JF------7LJ|F-JF7-LJLJ-7.|JF7J.L7||
F.|7FFJL---JL--JL7F-JL-7|FJL-JF7|F7L-77FJL--7||L--7F7FJLJL7F-7LJL-7||L7|FJ|F-JLJLJLJ|F--7|F7F7LJ|L--------JF7F7F7L-7|L--JL--7J-LJ7LLJ||-J.|7
777|7..FF---7F---JL7F--JLJF7F7||||L-7L-JF7F-JLJF77LJLJF7F7||7|F7F7|||FJ||FJL7F----7FJL-7|LJLJL-7|F--7-F----JLJLJL--J|F-----7|-F-LF7FLL-JF-JJ
L-|J-L-FL--7|L----7LJF--7FJ||||LJL-7L---JLJ|F7J|L-----JLJ|LJFJ|||LJ|||FJLJJ-LJF---J|F7FJL------JLJF7L-JF-------7F7F7|L----7LJ7|--.|-...--7.F
FLF.FLF7|F7|L7F7F-JF-JF-J||LJLJF---JF7F7F---JL-JF-7F-----JF-JFJ|L-7||LJJJ.LFJFJF--7LJLJF7F7F-7F7F7|L7F-JF---7F7LJLJ||F7F7FJF-7--FF|LF|77FF--
J|L-7-|L7||L7|||L--JF-JF7|F7-F7L----JLJLJF--7F7FJFJL--7F-7L-7L7|F7|||JJ|L7-F7L7|F-JF--7|||||FJ|||||FJ|F7L--7LJ|F---JLJLJ|L-JFJLF-F|7FJLFJ-J.
FFFL7-L7LJ|FJLJL--7FL--JLJ|L-JL---7F7F-7FJF-J||L7L---7LJFJFFJFJLJLJLJJF|7L-|L-J||F7|F-J|||LJL-JLJ||L7||L---JF-JL-----7F7L---J7-|L7L7L7LL.F-|
L-FF7|FL-7LJF-7F-7|F7F----JF-7F--7LJLJFJL7L-7||FJF--7|F-JF7L7|J7L|||JF-F-JLL7F7|LJ||L7FJ|L-7F----J|FJ|L7F7F7L-----7F7LJL7F-7.JJLLL-F--FL-7-|
.F7LL7F--JF7|FJ|FJLJLJF7F--JFJL7JL---7L--JF7LJ||FJF-JLJF-JL7||J|7.|.LL.J.F-FJ|||F-JL7||LL--JL--7F-J|FJ7LJLJL-----7LJL---J|FJ7-F77FFL7J|L7L-|
-|77|L|F7FJLJL7||F7F7FJLJF--JF-JF----JF7F7||F7LJ|FJ-F-7|F--JLJ.|J7L77L----J|FJLJL---J||F7F-7F-7LJF-J|F7F7F---7F-7L-7|F7F-JL7--FFJ---J.JF7FFJ
..L77L||||..F7LJLJ||||F--JF-7|F-JF----JLJLJLJL--JL--JFJ|L-----7.||F7J7|F|..LJJL7JF7F7LJ||L7LJFJF7L--J|LJLJF77LJ|L-7L-JLJF7FJFF|.F-J||-LL-7LF
|.JL-JLJLJF-JL----J|LJ|F7FJLLJL7FJF----7F7F7F7F-7F--7L7|F7F7F-JFF7|JLLJJ77.JL77FFJLJL--J|FL7FJFJL7FF7L----JL---7F7L7F---JLJ-LJ|F|7FJ-F-JLLJL
L-||-||F--JF7F-----JF7LJ|L7FF7FLJLL---7LJLJLJ|L7|L-7L-J||LJLJ-LFJ|J|.F|JLF7..L|JL7F-7F-7L--JL7L-7L7||F---------J|L7|L-----77L7|F777|JJ..FJ-J
L-JF-JFL7F7|LJF----7||F7|FJFJL--------JF7-F7-L-JL--JF--JL--7.F-|FJ.LFLJJ.|F7..|FFJ||||JL--7F7|F7L7|||L-----7F--7|FJL-----7L-7F7F777JJ.L-|JF7
.-.F7L|JLJLJF7L---7||||LJL7L-----------JL7|L---7F--7|F-----J-7-||LJFLJ-LLFLJ-F-7L-JFJ|F--7LJ|LJL-JLJL7F----J|F-J|L7F7F7F7L--J||||||J-F.JJF-F
FL7L-JF.|.|FJL-7F-JLJLJF--JFF------------J|F---JL-7|||F---7F-77||7JF7|7LL77.-L7|-|7L-JL-7|F-JF------7LJF-7F-JL7F|FJ|LJLJL7JF7|LJL-7F7|..FF7|
7FJ-J-JLJF7L7F7LJF-7F-7L7F--JF-7F7F---7F-7||F7LF7-|||||F--JL7|FJL7.||F7.7LJ-.F|L7F7F7F7F||L--JF-7F-7L--JFJ|F--JFJ|FJF--7FJFJ||F---J-7J7FFL77
|-7-|..|7|L-J||F7|FJ|FJFJL-7FJLLJLJF--J|FJ||||FJL7|LJLJL----JLJF7|.|LJ|7L7..7-L7||LJ|||FJL--7JL7LJFJJF-7L-JL-7||FJ|FJF7LJ|L7|||F-7..LFJ7-FJ7
7||F|.7LFL---JLJLJL7|L7|F-7LJF7F7F7L---JL-JLJLJF-J|F---7F------JLJ.L-7L7F7F7J-F||L-7LJLJF7F7L-7L-7L-7L7L--7F7L-JL-JL-JL-7F7|LJLJFJ7L.F-FF-JJ
L7-L7.777LLF---7|F-J|FJ|L7L--JLJLJL-----7F--7F7L--JL--7|L--7F-7F7FJJ7L7|||||7F7||F7L--7FJLJL-7L-7L-7|FL7F7LJL7F-7F-7F--7LJLJF---JF7L7L7.JJ.J
F|7.J..-7.LL7F7L7L--J|FJFJF---7F------7FJ|F7LJ|F7F7F-7|L---JL7|||7JJF7||||||FJLJLJ|F7-LJF7F7FL-7|F-J|F7LJL--7|L7|L7|L-7L---7L----JL-77.-J|7.
-J|7L77JLFFFJ|L7L-7F7LJJL-JF7|||F-----JL-J||F7||LJ|L7|L------JLJL-7.|LJLJLJ||F---7||L---JLJL---JLJF7LJL-----JL-J|FJL-7L-7F7L-7F7F7F-J--J.FJ.
|JLF.|J|F-LL-J7L-7LJL-7F7F-JL7LJL7F7-F--7FJLJ||L7LL7||F7F7F--7F7F7|-L7F7F-7|||F-7||L---------7F7F-J|F7F--------7|L-7FJF7LJL7.LJLJLJ.J.LF-JJ.
L7LL7JF-L-FF7F7F7L---7||||F-7|F7JLJL-JF-J|F--JL7L-7||||LJ|L-7||||LJF7LJ||.LJLJL7||L-7F-7F----J||L7FLJLJF------7||F7||FJ|F-7L--7F7.LF|---J7.F
LJF-JFF.|FFJ||LJL7F--J|||LJFJLJL-7F--7L--JL--7JL--J||||F7L--JLJLJ.FJL--JL-7F7F7|LJF7|L7LJF7F-7|L7L7F-7FJF--7F7LJLJLJLJJLJFJF7FJ|L---7..|.--J
L7J.FJ|LF7L7LJF-7LJF-7LJL7FJF7F-7|L-7|F-7F7F7L----7LJ|||L7F7F7F7F7L----7F-J|||||F7|LJL|F7|LJLLJ-L-JL7|L-JF-J|L7F7JF-7F--7L-JLJFJF-7FJ777...|
.L|FLJL.||LL--J|L7FJLL--7LJFJLJFJL--JLJ-|||||F7F7FJF7LJL7LJLJLJ|||F7F7FJL7L|LJ|LJ||7F7||LJF7-F7F7FF7||F7FL-7L7LJ|FJFJ|F-JF7F--JFJ7LJLF-7---J
|||LJ..F|L7F7F7F7LJF----JF7|F7FJF--7F7F7LJLJLJLJ||FJL--7|F-----J|||LJLJF7L7L-7L7FJL7||LJF-JL-JLJ|FJLJLJL---JFJF-JL7L-JL--J||F--JF7F7-7J77.F|
LJJ.|.-FJFJ||||||F7L----7|LJ||L-JF7LJLJL-7F--7F7LJL7F--J|L---7F7||L-7F-JL7|F7L7||F-J||F7L7F----7LJF-7F-7F7F7|FJLF-JF------J||-F7|LJL7J|FJ-FJ
FF|-|.|L7L-JLJLJLJ|F77F7LJF-JL---JL----7FJ|F-J||F7F|L7|FJF7F7LJ||L7LLJ-F7||||FJ||L7FJ||L7LJFF7|L--JJ||7LJLJLJL-7|F7L7F7F7F7||FJLJF--JJL|FFJJ
FFJF--F-JF-7F----7|||FJ|F7L----7F-----7|L-JL--JLJL7L7|FJFJ||L-7|L7|F7F7|LJLJ|L7||FJL7||FJFF-JL------J|F----7F-7LJ|L-J|LJLJLJLJF7FJF7..FF7J.|
FF7JJ7L7FJLLJF7F-JLJ|L7||L7F-77LJF--7FJL-------7F-JL|LJFJFLJF7LJ-||||||L--7FJ7||||-FJ|||F7L--7F7F7F7FJL---7LJFJF7L7JFJF7F--7F7|LJ||L7F7|J7.F
J|L.L|JLJJ-FFJLJF7F7L-JLJFJL7|F7FJF7LJ7F7F7F--7||F-7L7FJF7.FJ|LF-J|||||F7FJL7FJ||L7L7||LJL7F-J|LJ||||F----JF-JFJL7L-JFJ|L-7LJLJ-F7L7LJL7FJ-|
FFL7||7|L-F-JF-7|||L--7F-J|L||||L-JL---J||LJF-JLJL7L-JL7|L7L7L7L-7||||||||F-JL7||FJ-|LJF--JL--JF-J|LJL----7|F7L-7L---J.L-7L-----J|FJF-7L7-FF
F|7.J|LFJ-L--J.||||F--JL7F7FJLJL-7|F-7F7LJF7L-7LF7L--7FJL7L7|FJF-J||||LJLJL-7J||||F7|F-JF7F-7F7L--JF------JLJL-7L------7.L7F-7F-7LJFJ-L-J.FJ
L.L-|L7LLFF----J|LJL-7F7|||L----7L-JFJ|L-7|L-7L-J|F--J|F7|FJ|L7|F7LJ||F-7F--JFJLJ||||L-7||L7||L----JF7F7F-7F-7.L------7L-7|||LJJL-7L777|FF-J
.-..-FJJ.FJF--7FJF---J||LJL-7F-7L7F7L7|F7|L-7L7F7|L--7LJLJL-JFJ||L7FJLJFJ|F-7L--7LJLJF7||L7||L-----7|||LJFJL7L7F---7F7L--JLJF7-F77L-JL|LFJJ-
F--|JL7J.L7|F7||FL---7||F7F7|L7L-J|L7|||LJF-J|LJ||F--JF-----7L7LJ-||F-7L7||FJF-7L7F--J||L7|||-F-7F7||LJF-JF7L7||F--J|L7F-7-FJL-JL-7FL7|F-JJ.
LJLJ.LJLF7LJ|LJ|F----J|||LJ|L-JF--JFJLJL-7L--7F7LJL--7|LF7F7L-JF7FJ|L7L-J||L7L7L-JL--7LJFJ||L7L7||LJ|F-JF7||7||||F7F|FJL7L-JF7F---J7||77LL|7
FF-7.|.F|L7|L--JL7F-7FJLJF-JF--JF--JF7F7FJF--J|L7FF7FJL7|||L7F7|LJFJJL--7||FJFJF-7F--JF7L7LJFJFJ|L7FJL--JLJL-JLJLJL-JL--JF7FJ|L----77.F7--77
L|FL-J-FL7L-7F-7LLJ|LJF7FL--JF7-L---JLJ|L-JJF7|FJFJLJF-J|||FJ||L-7L-7FF7|LJL7|FJJ|L-7FJL7L-7L7L7||LJF---7F7F7F7F-7F------JLJ7L7F7F7L7..|.L|J
F|FJ.FF77L-7|L7|F7F---J|F77F-JL-7F7F---JF7F7|||L7L7F7L7FJLJL-JL-7L7FJFJ|L-7FJ|L-7|F7|L7FJF7|FJ7|L-7FJF-7LJLJLJLJFJL------7F-7L|||||FJ.7JJFJJ
J-77LL|L---JL7||||L---7LJL7L---7|||L--7FJ||LJ|L7L7LJ|FJ|F-------JFJL7L7L--JL7|F-JLJLJFJL7||||F-JF-JL-J|L-------7L--7F7F--JL7|7LJLJLJF-J|J-.|
JJL--LL-----7LJLJ||F7.L7F7L----JLJL---J|FJL-7L7L7L7FJL-JL7F----7FL-7L7L----7LJ|F--7F7L-7|||||L7FJF7F--7F---7F-7L--7LJ|L--7FJL7F-7JJ.L7LL7.LF
FFL|7-|.F---JF7F7L-JL--J|L7F----------7|L7F7|FJL|FJL-7F-7LJF---JF7.|FJLF7|FJF-JL7FJ||F7|||LJ|FJL7||L-7|L--7LJFJF-7L-7L---JL7FJ|FJ|J|7F.FF|.L
F7||LFFFL-7F7|||L-7F-7F7|FJ|F---------JL7LJ||L7FJ|F7F||-L--JLF7FJ|FJL7FJL7L7L-7FJ|FJ||LJ|L-7||F-J||F-JL---JF7L-JLL-7L------JL-JL7J.7-JL-7|L7
F|7F-LJF7L|||||||FJ|FJ||||FJL-7F7F-7-F77L-7||FJL7|||FJ|F7F--7||L7|L7FJ|F-JFJF-JL7|L7|L7FJF7|LJ|F7||L-7F7F--JL-----7L7F7F-7F7F---JLF|.F|LFJF7
.LL--J7|L-J|||LJFJFJL7|||LJF--J|LJJL7|L7F7|||L-7|||LJFJ|||F-J||FJ|FJL7|L7FJFJF-7|L7|L7|L7|LJF-J|||L7|LJLJF--------J-LJ||7LJ|L---7L7LF.|.J.L7
|JJJ.J7L-7FJLJFLL7|F-J|||F7L--7|F---J|FJ|||||F-J||L-7|7||||F7||L7||F-JL7||FJ-|FJ|FJ|FJL7|L7FJF7|||FJF7|F7L------7F---7|L--7|F-7FJFF7--7-L7J|
|JFF|.FLLLJLF-7F7|||F-JLJ|L---J|L7F-7|L7|||LJ|F7||F7|L7|||LJ|||FJ||L7F7||||F-J|FJL7||F7|L7||FJ|||||FJ|FJ|F-----7LJF--JL-7FJ|L7LJFFJ||FJ--.F|
|LJJ-LJ7|LJ|L7|||||||F---JF7F--JJ||.|L7||||F-J|LJ||||F|||L7FJ|||FJ|-||LJ||||-FJL-7|||||L7LJLJFJ||||L7||.|L-7F7F|F7L----7LJ-L7L---JFJJ7.|L|7|
F7J|.|JFL|JFF|LJLJ|||L7F--JLJF7F7||FJFJLJ||L-7L-7|||L7||L7||FJ||L7|FJL7FJ||L7L7F-JLJ||L7L---7L7|LJL7|||FJF7LJL7LJ|F7F-7L-7F-JF7F7FJJLF-7-J|L
FJFFFJL-7|JF7|F7F7|||7LJF----JLJLJ|L7L--7LJF-JF-JLJ|FJ|L7|||L7||7LJL7FJ|FJL7|FJL---7||FJF7F7|FJ|F--J|LJL7||F-7|F7LJ|L7L--JL--JLJ||J-FF7L.FJ7
|LF.L-7J-J-|LJ|LJ||||F--JF7F7F7F7FJJL7F7L-7|F7L---7|L7L7|LJ|FJLJF7F7||L|L-7|||F----J||L7|||||L7|L7F7L--7|||L7|LJL-7|FJF------7J.LJ7FJLJ|-FLJ
L||L7.7F77.L-7|F7||||L---JLJ||||||F--J|L7FJ||L7F-7|L7L7||F-J|.F-JLJLJL7L7FJ|||L--7F7||FJ|LJ|L7||FJ|L7F7|LJ|FJL-7F-JLJFJF-7F-7|JF.|JL-FLL.L-7
FLL.|-|LF----JLJ|||||F------J|LJ||L7F7L7|L7LJ.||L|L7|FJLJ|F7L7L--7F--7|FJL7LJL7F7LJ|||L7L-7L7|LJL7|FJ|||JFJL-7FJL7F--JFJFJL7|L77-L-JF-J|--L7
|7|F--LJL-7F7F7FJ||LJL----7F-JF-J|FJ|L7|L7L-7FJL7|FJLJ-LFJ|L7L-7FJL7F||L-7L-7||||F7|LJ7L7FJFJL7F7||L7||L7L7F-JL7FJ|F--J-|F-JL-J|FLJ7FJFJ.L||
|--F7FJ.|LLJLJLJJ||F------JL7FJF-JL7|FJ|FJF-JL7FJ||-F7-FJFJFJF7||F7|FJ|F-JF-JFJ|||LJF7F7|L7L7FJ|LJ|FJ||FJFJL7F-JL-JL-7F7LJ-L|-FL7J-7|L|.|F-.
7.F-J-JFF-J.|||--LJL------7FJ|FJF--J|L7|L7L--7LJ7|L7|L-JFJ.L7|||||LJL7|L-7L-7L-J|L-7|LJ|L7|FJL7L7FJL7|LJLL7FJ|F-7F7F7LJL7||FJ-L.7J|LFF7-LJ-|
FLJJ7|FJJ7.LLJF--|LF------J|LLJLL-7FJ|||FJF7FJ|F-JFJL-7FJ.FFJ|LJ|L7F7LJF7L7FJF--JF-J|F-J.||L7FJ.LJ|FJL7FF-J|LLJ|||||L7F7L77|J7|7L77-FJJ|.J.|
FJJL-7-J.77FJF7|FLFJF-7F7F7L-7F---J|F-J||FJLJF-JF7|-F-JL-7FJFJF-JFJ|L--JL-JL7L7F7L--JL--7LJFJ|.F--7L-7L7|F7L---7||||J||L7L7|J-|F7.LL-J.|7|FJ
F7FF-J|F--.L7-LF|-L7|.LJLJ|F7|L7F7FJ|F7||L--7L-7||L7L-7F-JL7|FJF7L7L--7F--7FJL|||F7F7F-7|-FJFJFJF7L--JFJLJL7F7FJLJLJFJL7L-J-7J|-77|7|.FL7JJ.
|--7LL|JFL-.77..LFLLJF7F--J|LJ.LJ|L7||||L-7FJF-J||FJF-JL--7|||FJL-JFF7LJF-JL-7||||LJ|L7|L7|FJ7L7|L7F7FJF---J||L-7F7FJF7L-7|7J..F77LL--|F-.FL
LL|L..7--J|F|7.L|LLF-JLJF-7L-77F7L-JLJ|L7L||7L7FJ|L7L7F7F-J|||L--7F-JL--JF7F7||||L-7|FJL7||L7F7||F|||L7L-7F7||F7LJ|L7||F7L77FJ-J.L-L-JL7--7J
7F--L7L7|.FJL|7-JFLL-7F7L7L7FJFJL-----JFJFJL-7|L7|FJLLJ||F-J||F-7||F7F7F7|LJLJ||L7FJLJF7||L7LJ|LJFJ|L7L7FJ||||||F7L7||||L7L7-|.LL-7-L.F|FJJ|
F|7FFJJ77F7-F7|FJJJ||||L-J||||L7F7F--7FJ|L7F7|L7|||-F--J|L7FJ|L7LJLJLJLJ|L---7||FJL-7FJ|||FJF7|F-JFJJL7||FJ|||||||FJ|||L7L-JFJ-L-7..|7FJL--J
-F-L|7LJL-J-LF|-J-F-L||F---JL7FJ|||F-J|.F7||LJFJ|||FJF-7|FJ|LL7L7F7F----JF7F7||||F-7LJFJLJ|FJLJL7FJ.F7LJ||FJ||||||L7LJL7L-77JJ|L||-LL-FJF.FJ
||F||7|.-..LFJL7.L-.LLJ|F-7F-JL7|LJL-7L7|LJL7FJFJLJL7|FJ|L7L7-L7||LJF-7F7|LJLJ|||L7L7FJFF-JL-7F-JL-7||F-J|L7|LJ|||FJL|L|F7L7.FF-JF.L|LJ7JFL.
--FJ77J||J.F7L-L-7F7JF7||JLJ7LFJL7F--JFJL-7FJL7|7FF-J||FJFJFJF-J||F7|JLJ|L---7|||FJ-LJF7L-7F-JL7F-7LJ|L7FJL||F7LJLJ|.|FJ|L-J7FJF7.F-F7J--||7
FFFJ.|--L.7.|.|.FLJ-F|LJL-7J|JL--JL7F7L--7||F-JL7FJF7||L7L7|JL-7|LJLJF--JF7F-JLJ|L----JL7FJL7LFJL7|F7|FJ|LFJLJL-----7-L-JJ|.F|LL77J.JJ7J-|J7
FF.F|J..|7F7FFFFJ|J-LL7F--JL-JLF---J||F-7|LJ|F7FJL-JLJ|FJ-||F--J|7F7FL7F7||L77-FJF---7F7|L--JFJF7|||LJ|FJFJF7F7F----J.||FLL-7J|LJF77|.|-FJ-L
7L-L7FF7-F7F---JFJF-JLLJ-JLFJJL|F-7FJ|L7|L-7|||L--7-F-JL7FJ|L7F7|FJL--J|||L7L-7L7L--7|||L7|LLL7|LJ|L-7||LL-J|||L-7J7|7J-F.JF|-FJ-F7-J-L-|J||
J77F|-LJ|LFLJ|J.-JFL7.|L7..J7F.LJFJL7|FJ|F-JLJ|F-7L7L--7|L-JFJ|||L7F7F7|LJFL7FJF|F--J||L-J--FFJL-7L--JLJJL|L|||F7|F|7.|L77-F7-J.FJ.F.FJJ|FL|
L7-F|.L-J7|LFJJFJ|7L7-F-J7F-J77.FJF7|||FJL--7FJL7L-JL|7|||F-JFJ||FJ|LJ|L--7FJ|FFJL7|7LJJJJ|F-L7F-JJL|J|J7||.LJLJLJ-JF-F7J7|L|JL--F7|-J7F77||
FL-J.FLJF-7JJ|FL7J-J|L|-FJ|J..LFL-JLJLJ|F7F7||F-JJ.L|FFJ|FJF7|FJ|L7L-7|F7FJL7L7L-7L--7-|-FFJJ-LJJJ-LLFF.77|-.L|.LF|-L7J|7L-7J7.JJL7||L-.J-J7
L..|FJJ.FJ|7L-J|L|F-7.F-J.--77F.L|7||LFJ|LJLJLJJ.|7-J|L-JL7||||FJL|F7|||LJF7L7L7FJF7FJ-L--J.|.L-J7F7J.J7|LLLJ-LJFJJLLJF-|-FJ||J|||.|-JFFJ.||
FJ.77JF---JJ||.7-F|-|7LJJ..FL7L7----J||FJLJ|-|-|.LF7-LLJ7FLJLJ|L7FJ||||||FJL-JFJ|FJLJJ77.LLLJ.LFF-JJ.F.|L.LJ|-LF-JJ.LJ7.L-7.|..LLJF7FL|-7|L-
LF7.F.|.LF7FL--L7LJ7.L7J.7.|.F-F.|LJLFLJ7LLJLJ7|.LJ7|||7FJFLF-JFJL7|||LJ-L-7F-J-||JJJF--7.LL.F.F|FJ.FL7|.-77|7.7.-77LL7-L7|F|-F7|FLL7|L|LF7|
.LJ|LJ|7|LF7JJ.L7.--7JL77|.F7J7L--.|.77.L-7J-LFF-FJL7--77-J7L7FJ7.LJ|L7J|FLLJJFL||J|F---LJ-L-7J-JJFF.L-77LF-|J-FLJ|FF.||FJ-|JJ||LFJ.-7L7.FJ7
|-|||JF-7-7||LJ7J-|7|..F7LFJ7.F7F|.F7.---7||J.|L.F-77L|-|7F7FLJ.L7FLL-JFF7J|-F7L||7LJJ||||||LJ|F7FLFJJJ||7J|.LFFJLL7JFL-7J7L-F||.JF|FJ-|7L|-
|.LFJ-|JLF7-7-||L|||J.FFJ7.|F-7J|7.LL-7|FJF-7F||FF7||7L-|-LJLJLF.F|-|JL--7F77F--||-.LFJ-LL7F-FF.FL--JJ.LJ7-F.F7F7L||.-.FJLF.-J|-FJJL7..J|FFJ
F-|.F7|.FJ7FL-|-7F||L-J|F7F-L7J-7--F7FFLJLFFL7J|7|F-7F|.|LF7|.L|-LLJFJJ..L-JF7|FLJ.F||J||-J.F-JFL.-7|F-JFF7.--JJJFJ|||-|F|L-.FJLLJL7LFF-L|J7
.FJF|JFFJLL77||L-7LJ77F-||L-|J.||J.L7-7-L--77F7L-J7JL--7L-F-|7-F7LF-L7LFF-J.||7FL|7.F--J7F|.F777-LL7LL.|LF7-LFJLF7|L7|.LJ777F|-7|-FJ-.L7-7||
F-J-L--|.LFJ-F|-J-----|.LLLJL7-JJ.F-L-7-F---JLJLLLL.7LL|LFJ|L--LL---L7-FJ.L|--L-JLL7L7.LLLJ-FJL|J-LLJL.|.JJLLLJ.LLF.L77LL|-J-|-7JJ..L-7JJ.-J
+5
View File
@@ -0,0 +1,5 @@
..F7.
.FJ|.
SJ.L7
|F--J
LJ...
+80
View File
@@ -0,0 +1,80 @@
import numpy as np
import math
# | is a vertical pipe connecting north and south.
# - is a horizontal pipe connecting east and west.
# L is a 90-degree bend connecting north and east.
# J is a 90-degree bend connecting north and west.
# 7 is a 90-degree bend connecting south and west.
# F is a 90-degree bend connecting south and east.
def main():
with open("10-input.txt", "r") as file:
arr = []
for line in file.readlines():
char_array = []
for char in line.strip():
char_array.append(char)
arr.append(char_array)
matrix = np.array(arr)
print(matrix.shape)
indices = np.nonzero(matrix == "S")
row_indices, col_indices = indices
starting_pos = (row_indices[0], col_indices[0])
current_position: tuple = starting_pos
last_position: tuple = starting_pos
steps = 0
visited = []
while True:
visited.append(current_position)
current = matrix[current_position]
next_position = find_next(current, current_position, last_position)
print(f"steps: {steps}: current {current} next {next_position}")
last_position = current_position
current_position = next_position
steps += 1
if next_position == starting_pos:
break
half = steps / 2
print(math.ceil(half))
rows, cols = zip(*visited)
new_matrix = matrix[rows, cols]
print(new_matrix.shape)
def find_next(pipe: str, position: tuple, last_position: tuple):
row_index, col_index = position
last_row_index, last_col_index = last_position
# print(pipe)
match pipe:
case "|":
if last_row_index > row_index:
return (row_index - 1, col_index)
return (row_index + 1, col_index)
case "-":
if last_col_index > col_index:
return (row_index, col_index - 1)
return (row_index, col_index + 1)
case "L":
if last_col_index > col_index:
return (row_index - 1, col_index)
return (row_index, col_index + 1)
case "J":
if last_col_index < col_index:
return (row_index - 1, col_index)
return (row_index, col_index - 1)
case "7":
if last_col_index < col_index:
return (row_index + 1, col_index)
return (row_index, col_index - 1)
case "F":
if last_row_index > row_index:
return (row_index, col_index + 1)
return (row_index + 1, col_index)
case "S":
return (row_index + 1, col_index)
if __name__ == "__main__":
main()
+140
View File
@@ -0,0 +1,140 @@
.....................................................................................#......#...............................................
..#.....#.................................................................#........................#........................................
...............................#...............................................................................#.....#......................
.................................................#.............#...............................#...................................#........
..............#......#.................#...............#............#.............#..........................................#..............
.........................................................................................#.................#...............................#
.#..........................................................................................................................................
..........................#......#............................................#......#.................................#....................
.................................................................................................#..........................................
.........................................#..........#..........#............................................................#...............
......#.....#......#..........................#........................#....................................................................
....................................#.........................................................................#..........................#..
..................................................................................#.........................................................
...................................................................................................................#........................
.................................................................#........................................#.................................
.............................#..............................#..........................#.......#............................................
..........................................#.....#.............................#.............................................................
#..................#..................................................................................................................#.....
....................................#...................#..........................#...........................#..............#.............
........#................#...................#.............................................................................................#
...............................#....................#...........................................#...........................................
.......................................#..............................................#.....................................................
........................................................................#........#...........................#..............................
..................................#........#...................#........................................#.........#.................#.......
#................#........................................................................................................#.................
.........#.......................................#...............................................#.............................#........#...
...............................................................................................................#............................
.........................................................................................#..................................................
...........................................................#..................................#..........#...........................#......
......#.........................#..........................................................................................#................
....................#.....................#.......#...............................#.................................#.......................
..........................#..............................................#..................................................................
..........#..........................#.......................#...................................#..............#..............#...........#
......................................................#.....................................................................................
............................................................................................................................................
#...............................................#................#............................#.............................................
..................#......................#............................#................................#................................#...
............................................................................................................................................
....................................................#....................................#.............................#....................
..............#...................#................................#..........#..............................#.............................#
............................#...............................................................................................#...............
....#.................#.....................................#..........#............................................................#.......
......................................................#.....................................................................................
...........#..............................#.................................................#..........#.................#..................
.................................#..............#................#..........#.......#.......................................................
...................................................................................................................#..............#.........
#...........................................................................................................#...............................
........#.......#............................................................................................................#..............
............................#.....................#..........#......................................#.....................................#.
.....................................#.................................................#........................#...........................
.........................................................................................................................#...........#......
.......................#.............................#........................#.............................................................
..............#...............................#.................#..................#........#...............................................
...#......................................................................#.................................#..............................#
...................#..................#.............................................................................#........#..............
............................................................................................................................................
.........................#.........................#........................................................................................
......#......#.............................................#.............................#............#.....................................
.................................#......................................#...................................................................
.........................................#........................#..............................#.................#..............#.........
............................................................................................................................................
......................................................#.................................................#..............#..................#.
......................#......#...............#...................................#............................#.............................
....#...........#.................#............................................................#...............................#............
..........................................................................#..........................#......................................
..........................................#................................................#...............................#............#...
................................................................................................................#...........................
..........#....................................#...................................................................................#........
................................#....................#..............................................................#.......................
......#.......................................................#...............................#.............................................
#.......................#.....................................................................................................#.............
.................#...................#...........................................#..........................#...............................
.....................................................................#....................#.................................................
..............................#.................#.......#.........................................#.........................................
..#........................................................................#....................................#.........#.................
...........#............................#..........................................#.............................................#..........
......#.............................................................................................................#.....................#.
........................................................................................................#...................................
..............#...................#.........#...............................................................................................
........................................................#.............#..........#.....#..........#............................#............
.........#......................................................#...........................#...............................................
.........................................#...................................#.................................#............................
............................................................................................................................................
................#...................................................................#.................#..................#..................
.................................#..........................#.............#....................#................................#..........#
...#........................#.........................................................................................................#.....
.................................................#......................................#.....................#......#......................
...........................................#.........................#........#.............................................................
........#......#...................................................................................................................#.....#..
.#..................#..................................#.........#..........................................................................
..................................#.....#.................................#.................................................................
...................................................#.................................#......................................................
............................................................#...............................................................................
.............................................#......................#..........#............#.........................#......#..............
................................#...................................................................#.......................................
.....................................................#..................#......................................#............................
...#......................#.....................................................................................................#...........
...........#...........................................................................#..............................................#.....
................#..................................................#..............................................#.........................
.......................#......................................................................#.............................................
................................#........#.........#.....................#.....#......................#.....................................
.#..........................................................................................................................................
........................................................#................................#...................#..................#...........
.....................................#........#.................................................#.......................................#...
.........#...........#......................................................................................................................
....................................................#.............................................................#.................#.......
.............#............#........................................#.............#.....................#...................#...............#
..................#....................#.................................#.............#....................................................
................................................#...........................................................................................
.......................#...............................................................................................#....................
....#..........................................................#.....#..............#...........................................#...........
...............................................................................................#..................#.......................#.
.........#...................#............................................#.................................................................
.............................................................................................................#..............#......#........
...........................................................................................#................................................
.#...........................................................#..............................................................................
..............#..............................#........................................#.............#.......................................
....................................#..............#..............#.........#.............................#.............#.............#.....
....................#............................................................................................#..........................
.........................................................................................#..................................................
...........#............................#................#....................................................................#.............
.....#......................................................................................................#...............................
..................................#................................................#........#.............................................#.
.#................#......#...........................................................................#......................................
..............................................#.......................#................#............................................#.......
.........#............................#........................#..........................................#.....#......#....................
..............................................................................................#.............................................
........................................................................................................................................#...
..........................#........................#...............#................................#............................#..........
..#........................................#............#............................................................#......................
...............................#.....#........................................#.......#......................................#..............
.......................................................................................................#....................................
.....................................................#..............................................................................#.......
........#......................................#...........................#.............................................#.................#
...................#.....#......................................#.............................#.............................................
............#.........................#......................................................................#.......#.................#....
..............................#...................................................#.........................................................
............................................#.........................................................#.....................................
.......#..........................#................#.....#.............#....................................................................
..................#.........................................................#.............#.......................................#.........
+10
View File
@@ -0,0 +1,10 @@
...#......
.......#..
#.........
..........
......#...
.#........
.........#
..........
.......#..
#...#.....
+10
View File
@@ -0,0 +1,10 @@
...#......
.......#..
#.........
..........
......#...
.#........
.........#
..........
.......#..
#...#.....
+51
View File
@@ -0,0 +1,51 @@
import numpy as np
def main():
with open("11-input.txt", "r") as file:
arr = []
for line in file.readlines():
char_array = []
for char in line.strip():
char_array.append(char)
arr.append(char_array)
matrix = np.array(arr)
dot_columns = np.all(matrix == ".", axis=0)
dot_rows = np.all(matrix == ".", axis=1)
coordinates = np.array(np.nonzero(matrix == '#'))
distance = []
for i in range(0, coordinates.shape[1]):
row = coordinates[0, i]
col = coordinates[1, i]
for ii in range(i + 1, coordinates.shape[1]):
next_row = coordinates[0, ii]
next_col = coordinates[1, ii]
empty_rows_passed = get_rows_passed(dot_rows[min(row, next_row):max(row,next_row)])
empty_cols_passed = get_cols_passed(dot_columns[min(col, next_col):max(next_col, col)])
d = (abs(next_row - row) + (abs(next_col - col))) + (empty_cols_passed * 999_999) + (empty_rows_passed * 999_999)
item = i, ii, d
if distance.count(item) == 0:
distance.append(item)
print(distance)
print(len(distance))
s = 0
for d in distance:
s += d[2]
print(s)
def get_rows_passed(rows: []):
passed = 0
for r in rows:
if r:
passed += 1
return passed
def get_cols_passed(rows: []):
passed = 0
for r in rows:
if r:
passed += 1
return passed
if __name__ == "__main__":
main()
+1000
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -0,0 +1,6 @@
???.### 1,1,3
.??..??...?##. 1,1,3
?#?#?#?#?#?#?#? 1,3,1,6
????.#...#... 4,1,1
????.######..#####. 1,6,5
?###???????? 3,2,1
+52
View File
@@ -0,0 +1,52 @@
import numpy as np
import itertools
from itertools import groupby
import timeit
filename = "12-input.txt"
def main():
with open(filename, "r") as file:
combinations = []
for line in file:
combinations.append(get_combinations(line))
print(sum(combinations))
def get_combinations(line: str):
start_time = timeit.default_timer()
#print(f"Finding combinations for {line}")
split = line.split(" ")
springs = np.array(list(split[0]))
config = np.array(split[1].strip().split(",")).astype(int)
question_marks_indices = np.nonzero(springs == '?')[0]
all_combinations = []
combinations = itertools.product(['#', '.'], repeat=len(question_marks_indices))
for combination in combinations:
test_array = springs.copy()
for i, index in enumerate(question_marks_indices):
test_array[index] = combination[i]
if validate_combination(test_array, config):
all_combinations.append(test_array)
end_time = timeit.default_timer()
execution_time = end_time - start_time
print(f"combinations for {line} done in {execution_time} seconds. {len(all_combinations)} combinations found.")
return len(all_combinations)
def validate_combination(springs: [], config: []):
hash_indices = np.nonzero(springs == '#')[0]
if len(hash_indices) != config.sum():
return False
groups = [list(group) for key, group in groupby(springs) if key == '#']
for i, group in enumerate(groups):
if len(group) != config[i]:
return False
return True
if __name__ == "__main__":
main()
+1377
View File
File diff suppressed because it is too large Load Diff
+32
View File
@@ -0,0 +1,32 @@
#.##..##.
..#.##.#.
##......#
##......#
..#.##.#.
..##..##.
#.#.##.#.
#...##..#
#....#..#
..##..###
#####.##.
#####.##.
..##..###
#....#..#
.#.##.#.#
.##..##..
.#.##.#..
#......##
#......##
.#.##.#..
.##..##.#
#..#....#
###..##..
.##.#####
.##.#####
###..##..
#..#....#
#..##...#
+62
View File
@@ -0,0 +1,62 @@
import numpy as np
filename = "13-input.txt"
def main():
with open(filename, "r") as file:
arr = []
nr_reflections = 0
pattern = 0
for i, line in enumerate(file):
if line == "\n":
if arr:
pattern += 1
print(f"Pattern {pattern}")
matrix = np.array(arr)
r = get_reflections(matrix)
print(f"Found {r} reflections")
if r <= 0:
print("Rotating 90 degrees")
r = get_reflections(np.rot90(matrix)) * 100
print(f"Found {r} reflections")
nr_reflections += r
arr = []
continue
char_array = []
for char in line.strip():
char_array.append(char)
arr.append(char_array)
print(nr_reflections)
def get_reflections(matrix: []):
f = {}
for i in range(0, matrix.shape[0] - 1):
for ii in range(i, matrix.shape[1] + 1, 2):
part_matrix = matrix[:, i:ii]
first, second = fold_matrix(part_matrix)
if first.size > 0 and second.size > 0 and np.all(first == second):
#if np.all(np.any(part_matrix == '#', axis=1)):
print(f"Found reflection at {i}, {ii}")
f[part_matrix.size] = ((ii - i) // 2) + i
if not f:
return 0
# Sort the dictionary in descending order of keys
sorted_f = dict(sorted(f.items(), key=lambda item: item[0], reverse=True))
# Return the value of the first item in the sorted dictionary
return sorted_f.popitem()[1]
def fold_matrix(matrix: []):
if matrix.shape[1] % 2 != 0:
return np.empty(0), np.empty(0)
half = matrix.shape[1] // 2
first_half = matrix[:, :half]
second_half = np.flip(matrix[:, half:], axis=1)
# if len(matrix) % 2 != 0:
# second_half = np.vstack([second_half, np.zeros_like(first_half[0])])
return first_half, second_half
if __name__ == "__main__":
main()
+100
View File
@@ -0,0 +1,100 @@
#....O#O.......O.......#O.......#...#O#.O...O...O..O#..#.O......OOO.OOO...#O.O.........OO.#..O....O.
##.#O..........OO.#.#..#...O..O.O##....O.....#....O.#....O....O.#..OOO..#..O.OO..##.#O#OO..##OO..#..
#.O.#O.O.O.......#.....##.##......#.###..###........OO...#..OO.....O....O......OOO.OOO.......OO.O#.O
O#.....#......#..##O#O.#..#O#.O.O.#...O....O.#......#....#.....O.#........O....O...O..O#...O...#O...
O#..#.OO.O#..#O##.#.#..O...OO..#..O#...#.....O.#.OO#...O.OO.O.O.....#...#.O..##...O.#.O.....O.##..O#
..OOO...#O#...O...OO.#...#OO.....#O..#.#.#OO...O.O#.......#..O..O..##..O#.O.....#O..OO#......O.O.O.O
..O.......O.....##OO#OO.#..#...O.O...O...O...#OOOO.O.O..#..O....O....OO#O.O.OOOO...#OO#.OO.O.#...#.#
#..O.......O.O...O.....#.O...O.#.....##.#...#.#.O...O...#.O.....O....#........#.O.#.#O#......O#..O.O
..#.#OO..#..OO.#..O.O.OO....OOOO...OO#..O..O...OO.O..O.O...#..#.....#.......O...O.......##O#....#.O#
.O.O#..O..O.#OO..O...#.O..O##O..##OO.OO.O.OO.O#...O...O........#.O..#......O#O#.O........OO..O......
.O#...........O..#...O.O......#O..###O....#O...OO...........#OO....O..OO..O..O.#O..O......#.O.O..#..
O..O#....OO....#.##.O#....OO.......O.......O....##.O.O....O#...#.O.O###...#....#..#...#...#OO....O##
###.O..#O..#O.#.#......##...OO...#.....OO.#O#..#...#..##O..#...O#....#O#...O..O...O...O..O.O..O..#.O
OOO.#.#..O..O#.O....#...O.OO###.#........OO.#.O#.#.....O..O..O#...O.O.O#.#O......O.#OOO#.#O.#O.O..OO
...##O#..O.#O......OO.#..OO....OOOO#...O...O.#....#..O...........OOO#.O.OO..O..O...O.#..O..OO##.O#..
.#.....#..#.....#..#OOO.O#O..O#O#..O.....OO..O##.O.OOO...#O....#O...O#...#O..O#O##....#.....O.O..O.#
OO............O....O##..OO.#..O.O.....#O...#.##O.#.O.OO#....#...O..O.#.##...........##....O.OO..O...
.##O#OO......O#...OO#...##O.O.......O....OOO..O..#.#...OOO.#..#.#..O..O#..O.....#.#.OO...O.....O##.O
O..#OOO#.O...O.......O#....O.O...O......O.......OO....##......OO#.....##...O#.............O#.....O#.
..O..##OO..O...#..OO..#...#.O.O..#..O...O.###..O.......#.O....O.##....OO.#..O.......#.O.O...O.O.####
.....O..OOO##..#.........O......O..O.#O##O#..O#O......##..O.O..#.......#.O##.#..#.#....O.OO.O.#O....
##....O..#.....#O.O...O#O#O.#.....O#.O.#..#O..O...O.#.#.....O.......#O...............#O......OO#..#.
..#O....#.......O..#O..#.OO..O...##.O.....O.#....#O..O.#O.O#O...O...O........#..OOO#..#....OO.##..O.
.#O#OO....OO.O...O..#..#O.O..#...#..#O.O....O#..OO.....O.#....#O..#....O.....#O.#......OO#O.........
.O..#.O#..O#.O..#.#.......#O......O.....O.#O...#O.#.#..OO.O..#..O............#OO#..#..O..#O..O.O.#..
..#..O.......#O##O.......O.O#O....OOO..OOO..O.#..OO..#O..O#......#.###O.O.#O.#.....#..O.##.OO.#.....
.O.#...O...O...O#..O.##O...#.OO......OOO.OO..#...#...OO#..O.#...OO#....###..O.#..#.....#....O.O.....
....O.OO..O#........#.#.#O..#.O....O...###.....O.O.#O#....O...O...##.#O#..O.#......OO.#####..#...#O.
O...#OO..##O##.......O#.O#...OOO.....O.O..#..OO......O#.##....#......O##......#OO#.#.........OOOO..#
O.O..##..O..#.#O.....#.OO.O...OO..#...O...###.....O..#....#.....#..O.O..#O.O#OO....#..OO.OO#....OO..
.OOO#..#.O.........O..O...O........OO#....#..#..##....O.....#......O....O#.O.O.OO..##...O.#....#....
....O...##O...#...OO.#O....O..O.O.O....#...O#O#..##.O.......O#.#..OO.#...#....O.....O..O#O#..#.O....
..#....O.O....#..O.OO.......O#..OO......O.O...OO.......O..#..O....OO#..O.O......#.......#...#....#.O
.....O#.........#...O.O..O.O#..O....OO..O.....O....O..#O..O.O....#...#.OO..O.#.#..O.#O...#..O..#....
#....#..##...O#OO....#..#.#O...............#.O........O..#.##............#.O#...#..##...O.....#..#.O
#.OO...O...O##...#O#..O....O.O..OO..O.OO.#OO.O..O...O#........#O.O....#.#.OO.....O....#..#O..O.#.###
......O....#...........#...#.........O.O....#..#...#..#.O#....#.O.#.O..#...O..#.......O.#..O#...#...
.#O.OO#.#...#.O.#..OO....O.......O#OO.O...........#.OO..#...##.O.#....O....##O....#..#...O#..O.O..O.
.#..##...#.O#O.O..O.......O..#...OO#......##.#O.#.O#O...##..#.O...#O.....O....O.....#......O..#.....
#O.O.O.OO.....O#..#....O.O#.O.OO.O#..O.#O.....O#.O#.O.O.........O...#...O.O..#O.#.#O#......#OO...##.
....#O....#.#.#O.O.OO.O.#..O.O...#...#...O....O........O#O.......#OO.#.........#....OO...O..O.......
.#.O#O..#.O.#...O#O.#......#.....O.O.O.#OOOO..##OOO.O.O....O..O#OO......OOO..O.##...O.O.#.....O.O#O.
##..........O...O.#...#O............#O.O......O..O#.....O......O..##.O.#O#.#......#..#....O...#..O..
..#..#..O#..#..O#O.........O##......##O.O....##.OOO#..#........O#OO..#.#.O.OO.#.OO#O.#.O..#.......##
.OO....O..OO...O.#..O....#O......##O.OOO..#.#O...#......O..#.#.....O#...OO.#...#O###...O...#........
O...O..OO..#.....OOO.#..O.##....#.O..O.OOO..#...O.#O..........#...O##....O.O..O...O...O.O.#O..O#.O#.
OO.O#O.##O.#.#..O.O.#.#..#...O..O..#...OO.OOO..O.O...OOO.#..O..O..OO.O##O#.#O...O...#...O.#O.#......
..OO.#.##.............#..#O.......O.O.#O..O.OOOO....OO..O..........#O.#..O.##.........#.....O.......
.O..O.##O#...O.#.O.#.......##.#...#....O#..O..OO............###.....#.O.O......##.#..O...........O.#
.##...#OO.O.O#.....O..O.OO##O.#..O..O...OO..#..O.O..O.O.O....O..............O#.###OO.#.#.#O#....#...
..O#...#.....O.OOO.....#O..O.#.#.....##....##O#..............O...O..#O##.#..O.....O..#...O.#O...O..O
O..OO.O....##O##O#......O..#O.O........O##O...#...O..O.....O.##..#....OO#O..O..#.....##..OO....O..O.
OO#.#OO.....O###....#O..O...#...#O..#O.#.O#.O.....O#O.O..O....O....##.....#....O.....#O...##....O.#.
#.#..#O#..O.#.#OO..##...#...#..OO.#..O....O..#...OO....OO..#..#....#....#O#.O...OO...#O..........O..
O..O.O.....O.....#.........O....O#......OO#..O..#.#.O##..#O.#..#...#..O.O......#.O..O..#.O......OO..
.#.......#..#.O.....O.#O#.#.#.....#O####.......O.#O........###..##...##..O..##...O.OO..#..O.O......#
.#.O.#.........#O.O.O...O..OO...O..O.O..O....O#..........O...O.O#.OO#..OOO.O..#O.O.O#O..O#.#..#OO..O
#.#.#...#.#.....#..#........O..#..#..###..O..O...O.O#..##.OOO.O...O.#O...O.......OOO#....#.#...O.#..
...#.O...O#O..O...#..O..O..O#.#...#..#....O.O..O...OO.#..O.OO.##O..OOOOO..#......#..OO##...OOO..O..O
.O...O..O.#O.....OO...#OO#..O#.....O..#.O.#.O#.O.##.O.OOO#OO..#..OO#OOO.O....O.....O#O.O..O..O##.O##
O.O.............O.......OOO#.....#.......#....#.O..##.#...#...OO......#..#..O.O...O.#.O.O..##O#..#..
O...#...##.O.#.##.O#.#..............O.O.#......###...OO......O.#..#.#O.......O#.#.O..O.OO#..O.....O.
OO#.....#.....#.#.#O.O#..#.#...........#...##.....#....O#...#....O#..#O.#O......O#.#.#.O..#.O##...#.
..#....O..##..#.###.OO.#......O..................##O#O....#OO#......O..O...##.##O....OO..#..#OO##.##
...#........O.#...O.##.#..#O..O......#....O##.#..OO..O#..#O......O.....#..O..#.OO.O.#..OO....O..#.#O
.O#..O......O.#OOO.....#.O...OO#.#.........#...O...O.#...##O.........#O#.O.#.#O.#..#.##.....O...OO..
.....OOOO..O.O####..#.O....#..OO......O.O.......OO#OO#O.OO..O##....#.........OO...#....O.O..O..#....
#O...#..#...O.OO#..##O...O.#......O..O##.#...#....OO..#...#..O....#.O...O##.#O#....#...#...O.O...#.O
..#.OOO.....O#......##.....#..O#O...#..#...........O#O.OO...#....#.........O....#..O.#...#..#..#.#O.
...OO.#..O...O..#.#O.##O.#..O.O.#O....O.....#..#O#.O....O.OO#.O..#..#...#...O...##.#.....O......O#O.
.###O....#......O.O..O...#...O..#......O.........O..O...##....#.#...#..........O##O...#..O..O.OO##..
..O.#O.O#...#..O#...O..#O..#.OO.....#.O.....##.O##.##...O..#...#O.O...#......#O...O...OO.#....O#..O.
...O.O...O.O.O.O#O.###..#.##O......O.O.O#..O...#.#O.O...##..##O.OOOO...#...O....O.##O#O.....#O#..O#O
....OOO#.....O..O.......#O#...........#.....#.#.#.....O..OO#.....O.OO..#...####.O.#O#.....#..#....OO
O##..OO..O#.#..O...#.....OOO......O.....O.....O#OO....O...O....O.#...#...OO...#..#....#.......O#.O.#
..#OOOOO.O#..#....##O.O#.....O.O.......O#......O#..#......#.O##.#...#O...O........O......O.O..O.....
..OO........O..O#..O.O.#..O.O#.O#...O.......##..O#......#O.O.#.#......O..#..#O.O.#.#.O#......##O.O..
.#......#..#...O..OOOO#.O#..........O.....#...OOO...O...O.#O..O..O...O..O...#.O....#O#......OO..OO..
...OO....O#O#OO...O.OOO.#...O.....#.O..O.O....#.O.#.O.#.#O.....O..#.##...OO#..#.O....#O.#.O.#O.O.#..
..#..#..O......#.#O.O...#.OO.....OOO...###.....O...O#..##.O...##O#..#.O.#.....O..#..O.O.OOOO..O...##
.#....O.O.O..O.O........O.#O..#OO#.##..O#..#.....OO#..O.#O..O..#.......O..#.....##....O..O.O#.......
....O...#OOO..##O...#OO...O...O......##......O....O..O..O....OO..#O..#....#..OO##.O.#.#.#...#.OO#...
.OO#..#...O.......O..#....OO..O#.....OO.##...##...#O......O.....#........#.##.O.....O..O..O..O.....O
.O..O#...#..O.OO...O....##.O..##...O..##O.#....O#.O....O...O.#O....#O......OO#..........O....##OO.#.
..OO..##.#.O.O....O....#O...O#......##......O.O.O#......O.#O......##.O.......O....OO#O.O..##O.O...O.
#.O....#..##........O#O.OO.#.#..OOO.#.O...#.##...#.O#....#.......#..O#O....O.O...O..O....OO.O#....O.
..#....OO..........O##.##..O..#..O.......#.........##OO....#.O...O.O##.......OO...#O#....O..##..OO..
#O.##O#....#.OOO.......O..#.O.O..O.#.OOOO#.#.#...##.O.OO......O..OO#.#...#.O##O.O........O.#...O.#..
#....O.OO#.#....O.#...O....#..O...#..O.OO..O..#..#..O#.#..OOO.O.O..#.O.#.#.......#.O#..O.##....OO...
..#.....#.O...O.O...O...O.#.#.O...OO#.#.#.....O#O.OOO.O.#......O.O.....O.#..O....O.O.OOOO#...O#.##.#
..O.O#O..OO......O......OO.#.#.....OO#...O..O......OOO..#..O...O#.##..O...#.......#.#.O....#..##.O.O
...O..#O..O#O...#..#...##.#....O.#...#.OOO.#O.......O...O....#...O...##...O..O..#..#...O#O..#...#.O.
..#..##.O#O...OO##..#..OO.#......O......O....#.#.O..O.......OO.#O.......#O...#.O.O.#....##O#O..OO...
.OO...O..O...#.OOO..OO.O...#O.......#.#.....OO..O..#.OO###.O.#O........#O.O#.O...............O.....#
....#O..#..#....O.##O.O#.O...#O..O#..#....O#.O...O....O......##...##O...#.#...#..#.O..O..#..#..O.O#O
.....#..O#...O.#.#.#......#O.O..#.#....O....##.O##O..O.#O..O.O.....#O....#..#.#..O.#O#......OOO#...O
.#..O...##.O.....##.#....#O.O.##..#.......O.....#.#..O##........#.O..........#.#O.#..#......#O#..#O.
OO.#...O...O#.......OO.OOO#.O#....#.OO...O..OO....OO#O.O#....O..O....O..O.O..O....O........O.O.#....
.O...#.......O..#OO.....#O.O...#O.#O..#.#.....#....O....#.....O..#O.#.O......O.O.OOOO.....O...#....#
.#OO.....#.#O..O........O.#O..O..#......O.O....OO.#..OO#..O#.#O.#O.O...#......O#O....#.#O...#...#.OO
+10
View File
@@ -0,0 +1,10 @@
O....#....
O.OO#....#
.....##...
OO.#O....O
.O.....O#.
O.#..O.#.#
..O..#O..O
.......O..
#....###..
#OO..#....
+56
View File
@@ -0,0 +1,56 @@
import os
import sys
import numpy as np
sys.path.insert(1, os.path.join(sys.path[0], ".."))
file_path = '14-test-input.txt'
with open(file_path, 'r') as file:
lines = file.readlines()
map_ = {"#": -1, "O": 0, ".": 1}
array = np.array([[map_[char] for char in line.strip() ]for line in lines])
nrows, ncols = array.shape
def cycle(array):
for i in range(4):
array = roll(array)
array = np.rot90(array, -1)
return array
def hash_(array):
return tuple(array.ravel())
def score(array):
rolls = np.where(array == 0)[0]
return (nrows - rolls).sum()
def roll(array):
for i in range(ncols):
rocks = [-1] + list(np.where(array[:, i] == -1)[0]) + [None]
for j in range(len(rocks) - 1):
left, right = rocks[j] + 1, rocks[j + 1]
array[left:right, i] = np.sort(array[left:right, i])
return array
seen = {}
scores = {}
maxval = 1_000_000_000
reverse_map = {-1: "#", 0: "O", 1: "."}
for i in range(maxval):
h = hash_(array)
if h in seen:
print(array)
print(f"Found cycle at {i+1}")
break
seen[h] = i
scores[i] = score(array)
array = cycle(array)
cycle_length = i - seen[h]
index = seen[h] + (maxval - seen[h]) % cycle_length
print(scores[index])
+63
View File
@@ -0,0 +1,63 @@
import numpy as np
def hash_(array):
return tuple(array.ravel())
def score(matrix):
total_count = 0
for i in range(matrix.shape[0]):
row = matrix[i, :]
count_O = np.count_nonzero(row == 'O') * (matrix.shape[0] - i)
total_count += count_O
#print(f"Row {i + 1} has {count_O} 'O's")
print(f"Total count: {total_count}")
return total_count
# Read the file
file_path = '14-input.txt'
with open(file_path, 'r') as file:
lines = file.readlines()
# Split each line into individual characters
lines = [list(line.strip()) for line in lines]
# Build a NumPy matrix of all the lines
matrix = np.array(lines)
seen_matrices = []
seen = {}
scores = {}
maxval = 1_000_000_000
# Loop through each column in the matrix
for cycle in range(maxval):
print(f"Cycle {cycle + 1}")
h = hash_(matrix)
if h in seen:
print(matrix)
scores[cycle] = score(matrix)
print(f"Found cycle at {cycle + 1}")
break
seen[h] = cycle
s = score(matrix)
scores[cycle] = s
for s in range(4):
for i in range(matrix.shape[1]):
column = matrix[:, i]
c_length = column.shape[0]
if np.any(column == 'O'):
for c in range(c_length):
if column[c] == '.':
for r in range(c, c_length):
if column[r] == '#':
break
if column[r] == 'O':
column[c] = 'O'
column[r] = '.'
break
matrix = np.rot90(matrix, -1)
print(scores)
cycle_length = cycle - seen[h]
index = seen[h] + (maxval - seen[h]) % cycle_length
print(f"Total count: {scores[index]}")
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
rn=1,cm-,qp=3,cm=2,qp-,pc=4,ot=9,ab=5,pc-,pc=6,ot=7
+67
View File
@@ -0,0 +1,67 @@
class Box:
def __init__(self):
self.lenses = []
def add_lens(self, lens_to_add):
for i, lens in enumerate(self.lenses):
if lens[0] == lens_to_add[0]:
self.lenses[i] = lens_to_add
return
self.lenses.append(lens_to_add)
def remove_lens(self, lens_to_remove):
for i, lens in enumerate(self.lenses):
if lens[0] == lens_to_remove[0]:
self.lenses.pop(i)
return
def power(self, idx: int):
total = 0
if len(self.lenses) == 0:
return 0
for i, lens in enumerate(self.lenses):
if lens[1] is None:
continue
total += lens[1] * (i + 1) * (idx + 1)
return total
def __str__(self):
return str(self.lenses)
def get_hash(word: str):
array_total = 0
ascii_num = [ord(char) for char in word]
for num in ascii_num:
array_total += num
array_total *= 17
array_total = array_total % 256
return array_total
# Read the file
file_path = '15-input.txt'
with open(file_path, 'r') as file:
line = file.readline()
# Split each line into individual characters
words = line.split(',')
boxes = [Box() for _ in range(256)]
print(words)
total = 0
for word in words:
if word.count('-') == 1:
start, end = word.split('-')
box_idx = get_hash(start)
boxes[box_idx].remove_lens((start, None))
else:
start, end = word.split('=')
box_idx = get_hash(start)
boxes[box_idx].add_lens((start, int(end)))
for i, box in enumerate(boxes):
total += box.power(i)
print(total)
+57
View File
@@ -0,0 +1,57 @@
import numpy as np
class Beam:
def __init__(self, start_loc: tuple, current_loc: tuple):
self.start_loc = start_loc
self.current_loc = current_loc
self.direction = None
self.beam_length = 0
self.energized = set()
self.active = True
def move(self, matrix: np.ndarray):
if self.direction is None:
self.direction = matrix[self.current_loc]
next_loc = get_next(self.current_loc, self.direction, matrix.shape)
if not (0 <= next_loc[0] < matrix.shape[0] and 0 <= next_loc[1] < matrix.shape[1]):
self.active = False
return None
self.current_loc = next_loc
self.beam_length += 1
return next_loc
def get_next(prev_loc: tuple, direction: str, shape: tuple):
match direction:
case '-':
return (prev_loc[0], prev_loc[1] - 1)
case '/':
return (prev_loc[0], prev_loc[1] + 1)
case '\\':
return (prev_loc[0] - 1, prev_loc[1])
case '|':
return (prev_loc[0] + 1, prev_loc[1])
case '.':
return prev_loc
file_path = '16-input.txt'
with open(file_path, 'r') as file:
lines = file.readlines()
# Split each line into individual characters
lines = [list(line.strip()) for line in lines]
# Build a NumPy matrix of all the lines
matrix = np.array(lines)
shape = matrix.shape
traverse = True
current_loc = (0, 0)
beams = []
beams.append(Beam(current_loc, current_loc))
while(traverse):
for beam in beams:
if beam.active:
next = beam.move(matrix)
+100
View File
@@ -0,0 +1,100 @@
Game 1: 2 blue, 3 red; 3 green, 3 blue, 6 red; 4 blue, 6 red; 2 green, 2 blue, 9 red; 2 red, 4 blue
Game 2: 4 red, 1 green; 3 red; 13 green, 5 red, 3 blue; 3 green, 2 red; 3 blue, 5 red, 3 green; 2 red, 3 blue, 12 green
Game 3: 4 red, 1 green, 1 blue; 1 red, 1 blue; 6 red, 1 green; 6 red, 3 blue, 1 green; 4 red
Game 4: 4 blue, 12 red, 4 green; 6 green, 3 blue, 19 red; 3 blue, 2 red, 2 green
Game 5: 1 red, 5 blue, 16 green; 1 red, 6 green, 3 blue; 2 red, 12 blue; 17 blue, 3 green; 7 green, 2 red, 6 blue
Game 6: 3 green, 1 blue, 5 red; 5 green, 5 red; 2 green, 2 blue, 3 red; 5 green, 2 red; 3 green, 6 red, 3 blue; 5 green, 4 red
Game 7: 15 blue, 1 red, 6 green; 4 blue, 7 green, 2 red; 14 blue, 5 green, 2 red
Game 8: 6 blue, 3 green, 10 red; 2 blue, 1 green, 5 red; 6 blue, 3 green, 12 red; 11 red, 1 green, 1 blue; 5 blue, 14 red, 3 green; 3 red
Game 9: 15 red, 3 blue; 1 blue, 16 red; 1 red, 3 blue; 1 blue, 1 green, 9 red
Game 10: 1 red; 1 blue, 7 green; 1 green, 5 blue; 3 blue, 3 green; 1 green
Game 11: 19 blue, 13 green; 19 blue, 2 green; 10 blue, 3 red, 12 green; 11 blue, 1 red, 6 green
Game 12: 7 green, 5 blue; 6 green, 3 red, 6 blue; 2 red, 5 blue, 15 green; 2 red, 1 blue, 1 green; 4 red, 4 green, 2 blue; 3 blue, 6 green
Game 13: 9 red, 2 blue, 2 green; 1 blue, 2 red, 15 green; 9 green, 2 blue, 9 red; 5 blue, 8 green, 5 red; 2 blue, 11 green, 5 red
Game 14: 9 blue, 1 red; 10 blue, 4 green, 3 red; 2 red, 6 blue; 4 green, 2 blue, 1 red; 5 green, 2 red, 11 blue; 12 blue, 2 red, 1 green
Game 15: 9 blue, 7 green, 12 red; 9 red, 17 green, 8 blue; 6 red, 4 blue, 4 green; 5 red, 17 green
Game 16: 5 green, 4 red; 3 blue, 3 red, 14 green; 6 red, 5 blue, 12 green
Game 17: 8 blue, 5 green, 2 red; 6 red, 6 blue; 9 red; 5 blue, 2 green, 8 red; 13 red, 4 blue, 4 green; 9 blue, 3 green, 5 red
Game 18: 8 green, 1 red, 2 blue; 4 green, 4 red, 1 blue; 6 blue, 2 red
Game 19: 3 green, 9 blue; 4 blue, 10 red; 6 red, 3 green, 3 blue; 6 red, 4 green, 9 blue
Game 20: 11 green, 3 blue; 6 green; 3 green, 6 blue; 1 red, 5 green; 6 blue, 7 green
Game 21: 1 green, 1 blue, 12 red; 6 red, 2 blue; 5 green, 4 red, 2 blue; 11 red, 8 green, 1 blue
Game 22: 10 red; 1 red, 13 green, 9 blue; 6 blue, 12 red, 12 green; 10 red, 8 blue, 11 green; 2 green, 1 red, 3 blue; 7 red, 1 blue, 8 green
Game 23: 11 red, 15 blue; 10 blue, 16 red, 1 green; 14 blue, 5 red; 1 green, 9 red, 9 blue; 1 red, 7 blue, 3 green; 6 red, 2 green, 3 blue
Game 24: 6 blue, 11 red; 16 green, 2 red, 1 blue; 8 red, 7 blue; 14 blue, 9 green, 9 red; 13 green, 4 red, 8 blue; 2 red, 7 blue, 1 green
Game 25: 2 green, 12 blue, 1 red; 10 blue, 5 red, 5 green; 2 blue, 9 red, 3 green; 5 blue, 4 red, 2 green
Game 26: 7 blue, 6 red, 1 green; 2 blue, 3 green, 12 red; 2 blue, 6 red, 5 green
Game 27: 2 green, 3 red; 4 green; 2 red, 1 blue, 1 green; 2 red, 1 green, 2 blue
Game 28: 11 blue, 1 red, 5 green; 2 blue, 2 red, 4 green; 10 blue, 4 red, 1 green
Game 29: 6 blue, 17 red, 1 green; 8 blue, 4 red; 14 blue, 1 red, 3 green
Game 30: 2 blue, 4 green; 7 green, 1 blue, 1 red; 1 blue, 8 green
Game 31: 15 blue, 9 green, 2 red; 5 green, 4 blue, 1 red; 1 green, 15 red, 7 blue; 5 red, 2 blue
Game 32: 1 blue, 5 red, 3 green; 3 green, 8 red, 1 blue; 5 green, 1 red; 4 green, 3 blue, 15 red; 2 green, 1 blue; 4 blue, 15 red, 4 green
Game 33: 3 red, 10 blue; 4 red, 9 blue; 1 green, 10 blue
Game 34: 3 blue, 1 green, 9 red; 4 green, 2 red, 9 blue; 7 blue, 3 red; 6 blue, 13 red; 4 green, 13 blue, 9 red
Game 35: 14 red, 1 green; 1 red, 2 green, 4 blue; 3 blue, 10 red, 6 green; 5 blue, 6 red, 7 green; 7 blue, 5 red
Game 36: 2 blue, 8 red, 9 green; 9 green, 3 red, 10 blue; 6 red, 8 blue, 1 green; 6 green, 8 red, 4 blue
Game 37: 10 green, 3 red, 6 blue; 2 blue, 9 red, 5 green; 13 green, 9 red, 10 blue; 2 blue, 4 green, 9 red
Game 38: 4 red, 14 blue, 12 green; 6 red, 12 green, 18 blue; 6 green, 1 blue, 1 red
Game 39: 5 red, 1 blue, 3 green; 1 blue, 3 green, 8 red; 15 red, 1 blue, 5 green; 3 green, 5 red; 1 blue, 14 red; 3 green, 1 blue, 12 red
Game 40: 8 green, 4 blue; 5 blue, 7 red, 8 green; 5 blue, 8 green; 6 green, 3 red, 12 blue; 14 blue, 7 green, 2 red; 1 green, 7 red, 5 blue
Game 41: 7 red, 10 green; 10 red, 6 green; 9 red, 7 green, 1 blue; 3 red, 1 blue
Game 42: 3 green, 2 blue, 13 red; 1 blue, 3 red; 11 green, 16 red; 3 green, 1 blue, 16 red; 5 red, 8 green
Game 43: 12 blue, 9 red; 16 blue, 2 red, 7 green; 4 red, 1 blue, 11 green; 15 blue, 4 red, 9 green
Game 44: 17 green, 5 blue, 2 red; 9 green, 11 blue, 1 red; 20 green, 3 blue, 8 red; 2 red, 13 green, 9 blue; 15 green, 12 blue; 4 blue, 7 green, 9 red
Game 45: 5 green; 5 green, 1 red; 3 green, 2 blue; 1 green, 1 blue, 1 red
Game 46: 10 red, 11 green; 16 green, 8 blue, 12 red; 9 green, 9 blue
Game 47: 20 green, 17 red, 1 blue; 16 red, 2 blue, 11 green; 3 blue, 19 red, 1 green; 3 blue, 17 red, 17 green; 12 green, 2 blue, 7 red
Game 48: 1 red, 4 blue, 6 green; 19 green, 1 red, 1 blue; 16 green, 3 blue, 1 red; 3 blue, 17 green; 4 blue, 12 green
Game 49: 13 green, 2 blue, 1 red; 1 green, 8 red, 2 blue; 11 red, 11 green, 3 blue; 7 red, 8 green, 4 blue
Game 50: 11 blue, 1 red, 2 green; 1 green, 10 blue; 1 blue; 6 blue; 1 green, 2 blue
Game 51: 3 red, 3 green, 1 blue; 3 green, 3 red; 10 green, 4 red; 3 red, 2 green
Game 52: 1 red, 4 blue; 1 green, 11 blue; 1 green, 3 red, 6 blue; 4 red, 1 green, 4 blue; 9 blue, 1 green; 10 blue, 1 green
Game 53: 2 blue, 4 green, 1 red; 8 blue, 4 red, 7 green; 9 red, 7 blue, 6 green; 3 red, 7 green, 1 blue; 2 red, 9 blue, 5 green; 1 green, 7 red, 10 blue
Game 54: 1 red, 1 blue, 5 green; 2 red, 1 green, 2 blue; 3 green, 3 blue, 2 red; 4 red; 12 red, 5 green, 2 blue
Game 55: 2 red, 11 blue; 16 green, 7 red, 16 blue; 4 blue, 11 green, 7 red; 8 green, 18 blue, 8 red
Game 56: 2 blue, 2 green, 1 red; 1 red, 1 green; 1 red; 4 green; 1 blue; 1 blue, 7 green
Game 57: 4 blue, 3 green; 16 green, 2 red, 5 blue; 1 red, 13 green, 2 blue; 3 blue, 12 green, 2 red; 2 red, 5 blue, 4 green; 10 green, 2 blue
Game 58: 3 blue, 8 green; 4 green, 3 blue; 7 green, 5 blue, 5 red; 8 green; 3 red, 6 blue, 9 green; 2 red, 10 green, 4 blue
Game 59: 7 blue, 6 green, 5 red; 7 red, 2 blue; 5 red, 11 green, 14 blue; 8 green, 17 red
Game 60: 3 green, 8 blue, 2 red; 4 green, 7 blue, 6 red; 13 blue, 8 green, 2 red; 10 red, 6 blue, 5 green; 11 green, 3 blue, 4 red; 9 red, 5 green, 9 blue
Game 61: 4 red, 18 blue, 13 green; 9 green, 5 red, 3 blue; 4 green, 3 blue, 4 red; 8 red, 4 green, 7 blue; 8 red, 4 blue, 6 green; 10 green, 5 red, 14 blue
Game 62: 12 red, 14 blue, 9 green; 9 blue, 6 red, 4 green; 2 red, 5 blue; 1 red, 12 blue
Game 63: 11 blue, 13 red, 11 green; 4 blue, 9 green; 8 blue, 9 red; 7 red, 11 green, 7 blue
Game 64: 10 blue, 8 red, 12 green; 10 red, 12 blue, 9 green; 3 green, 17 red; 12 green, 15 blue, 16 red; 6 green, 15 blue, 1 red; 9 red, 6 blue, 10 green
Game 65: 7 red, 7 blue; 3 blue, 1 red, 1 green; 3 red, 8 blue
Game 66: 1 blue, 3 red; 10 green, 5 blue; 4 green; 3 red, 11 green; 3 blue, 15 green, 3 red
Game 67: 1 red; 2 blue, 2 green, 1 red; 6 green, 1 blue
Game 68: 7 red, 4 blue; 4 blue, 6 red, 7 green; 2 green, 19 red, 11 blue; 11 green, 9 red
Game 69: 4 blue, 3 green, 1 red; 7 blue, 1 red, 3 green; 5 blue, 1 green; 2 blue, 10 green, 2 red; 2 red, 6 green, 5 blue; 1 red, 4 green, 2 blue
Game 70: 9 blue, 7 red, 6 green; 19 blue, 4 red, 5 green; 6 blue, 7 red, 4 green; 3 blue, 4 red, 2 green
Game 71: 6 green, 12 blue, 4 red; 11 red, 10 green, 11 blue; 3 red, 14 blue, 13 green; 4 blue, 3 green
Game 72: 2 green, 1 blue, 9 red; 10 red, 3 green, 1 blue; 11 red, 2 green; 2 green, 1 blue, 5 red; 1 red, 1 blue, 3 green; 13 red, 4 blue, 1 green
Game 73: 11 green, 6 blue; 7 green, 6 blue, 7 red; 12 green, 8 blue, 11 red; 4 red, 2 blue, 9 green; 4 green, 7 blue, 2 red
Game 74: 3 blue, 7 red; 3 blue, 5 green, 2 red; 5 red, 1 green, 3 blue; 8 green, 2 blue, 11 red; 3 blue, 8 green, 10 red
Game 75: 2 green; 5 blue; 1 blue, 1 red; 1 red, 9 blue, 2 green; 2 blue, 2 green
Game 76: 12 blue, 13 green; 5 red, 11 blue, 9 green; 12 green, 6 red
Game 77: 1 blue, 15 green, 12 red; 15 green, 5 blue; 14 green, 3 blue, 8 red
Game 78: 11 green, 8 blue, 1 red; 9 green, 8 blue, 1 red; 13 green, 5 red, 6 blue; 5 red, 7 green, 20 blue; 10 blue, 5 red
Game 79: 3 blue; 6 blue, 5 red; 4 red, 1 green, 4 blue; 7 blue, 6 red; 7 red, 1 blue; 1 red, 1 blue, 1 green
Game 80: 11 green, 3 red, 8 blue; 2 red, 15 green, 2 blue; 5 green, 8 blue, 2 red; 8 blue, 14 green; 2 blue, 13 green
Game 81: 9 red, 4 green; 7 green, 4 red; 2 red, 4 blue, 6 green; 6 red, 4 blue, 9 green; 1 green, 3 red; 6 green, 1 blue, 8 red
Game 82: 5 blue, 3 red, 3 green; 5 red; 2 red, 3 green, 8 blue
Game 83: 10 green, 1 red, 1 blue; 3 red, 1 green, 1 blue; 4 red, 10 green
Game 84: 16 red, 2 green, 6 blue; 6 red, 3 green, 8 blue; 3 green, 10 red, 5 blue; 4 blue, 3 green; 15 red
Game 85: 3 green, 2 red; 5 green, 4 blue; 5 green, 8 red, 3 blue
Game 86: 7 green, 16 blue, 7 red; 1 green, 12 red, 2 blue; 15 green, 16 blue, 7 red
Game 87: 1 red, 6 green, 5 blue; 2 green, 1 blue; 2 green, 1 red, 1 blue; 5 green, 4 blue
Game 88: 3 green, 3 red, 4 blue; 1 red, 1 green; 6 blue, 9 red, 1 green; 1 green, 11 red, 3 blue; 7 red, 6 blue
Game 89: 2 blue, 3 red, 4 green; 5 red, 7 blue, 14 green; 8 blue, 5 red, 16 green; 2 blue, 5 red, 7 green; 5 green, 9 blue, 1 red
Game 90: 1 blue, 3 red, 7 green; 11 green, 4 red, 1 blue; 1 red, 1 blue, 6 green; 2 blue, 2 green; 8 green, 2 blue; 3 red, 2 blue, 4 green
Game 91: 6 blue, 4 red, 1 green; 8 red, 3 blue, 3 green; 1 green, 2 blue, 5 red; 1 blue, 3 green
Game 92: 8 green, 1 red, 5 blue; 2 green, 7 blue; 11 blue, 5 green, 8 red; 7 blue, 3 red, 4 green
Game 93: 3 green, 1 red, 9 blue; 13 red, 5 blue, 8 green; 5 green, 2 red, 7 blue
Game 94: 4 green, 10 blue, 8 red; 4 red, 10 blue, 2 green; 2 green, 10 blue, 5 red; 5 green, 2 red, 10 blue
Game 95: 5 green, 1 blue; 3 blue, 11 green, 8 red; 8 blue, 2 red, 12 green; 4 green, 4 blue, 4 red
Game 96: 1 blue, 13 green; 8 blue, 3 red, 4 green; 1 red, 3 blue, 10 green
Game 97: 18 green, 4 red; 1 blue, 2 red, 9 green; 6 red, 3 blue, 10 green; 3 blue, 15 green, 4 red
Game 98: 2 blue, 3 green, 6 red; 1 green, 1 blue, 8 red; 8 red, 3 green, 1 blue; 2 blue; 8 red, 2 green, 2 blue
Game 99: 1 green, 2 red, 1 blue; 8 green, 4 blue, 1 red; 7 blue, 1 red, 11 green; 9 green, 3 blue; 1 red, 2 blue; 1 red, 6 blue
Game 100: 7 blue, 9 green, 2 red; 5 red, 9 green; 1 blue, 8 red, 13 green
+63
View File
@@ -0,0 +1,63 @@
import re
class Max:
def __init__(self, id, red, blue, green):
self.id = id
self.red = red
self.blue = blue
self.green = green
def isValid(self, maxRed, maxBlue, maxGreen):
valid = self.red <= maxRed and self.blue <= maxBlue and self.green <= maxGreen
return valid
def power(self):
return self.red * self.blue * self.green
def main():
maxRed = 12
maxBlue = 14
maxGreen = 13
with open("2-input.txt", 'r') as file:
array = []
for line in file:
array.append(parseLine(line))
result = 0
power = 0
for a in array:
if(a.isValid(maxRed, maxBlue, maxGreen)):
result += a.id
power += a.power()
print("power: " + power)
print("id addition: " + result)
def parseLine(s: str):
idSplit = s.split(":")
id = getID(idSplit[0])
green = 0
blue = 0
red = 0
roundSplit = idSplit[1].split(";")
for round in roundSplit:
colorSplit = round.split(",")
for color in colorSplit:
green = max(green, getColor(color, "green"))
blue = max(blue, getColor(color, "blue"))
red = max(red, getColor(color, "red"))
return Max(id, red, blue, green)
def getColor(s: str, color: str):
split = s.strip().split(" ")
if(color == split[1]):
return int(split[0])
return 0
def getID(split1):
digs = re.findall("\d+", split1)
id = digs[0]
return int(id)
if __name__ == "__main__":
main()
+10
View File
@@ -0,0 +1,10 @@
467..114..
...*......
..35..633.
......#...
617*......
.....+.58.
..592.....
......755.
...$.*....
.664.598..
+140
View File
@@ -0,0 +1,140 @@
416.........................559...............417...............785.......900.......284...........503...796....992..........................
.........702*....772............378..569.........&.49..606...14*..............$.453*.........307....*......$.....-.................995......
.....................458...856......+.........+....&..............680.......104.............%....516.................................*......
...........822..174..*.....&...........711.746.......&............$....../.............656....#...........265=......634.*.............430...
..827.137..*...*....39................*..............856..............767........522......$..773....619..............*...287....501.........
..........726...511.............*.....320........476...............................*................%...899....72..731...........%....$.....
.....861..............232....223.933...............*.@........424*618.858.......................................$.......338.205........535..
.......#.............-....................676...713...427.................-.......615.........126...................=..*.......*...&........
....40..........996..............520.974.*..........#......*.566........907......................&...214...996*911.115.363..960..897........
....+.............*....................$..172.....559...763.....*............554......*.............*.......................................
.......527...#.....90.+....66.................................890..............=...802.93.131..791...209......&........928......303....$....
950.....*....773......105..............725........................................................%............886.......*........$.384.....
........383......741..............@..=....#.....179.18..%974..........624.......64.266.................701...........%..671.721.........942.
..................*.............914..548..........+.*.................*...........*...................*.........834.394.....*...............
.......502*80..960........................25........464.........831.846........25.........329..985...458.+.....&................377..659....
..........................................*.....292...............*............/..................@......350........938............*....$...
...738..............428......+.......311...742.........236*631....816.&......+....86.........81.......................*.973*341.266.........
......*.....673......*......614.........*.......689.48.................450...816.....754...........258..@585.......154..............@.......
...231.....#.........681...........855...775..........*.....=..257...................................*.............................469..=682
........#...................807...&.............418.19.....259....*459..906...185.356.......778.......230....................556............
.......924.........459......*..............804.=.........................*...*...........&....*................=........836..+......618.....
.....=............#.......900........+...........702..383........%..*...250..503.......637.808.......97/....@...370.......&........#.....710
..988........685............../663.273...........*...@..........16.251...........$..............*..........964.......658.....537........*...
...............*......171*......................714.....543............737.....372.............941.............113..*....=.......853....733.
............470..161......508.....56...170.............$...................389.....544.....208.....98.........%.....617...884......-..@.....
.766.591............../.........-......*.......210.........618......*874....-.........#...*....129.=..194......../...................992....
....../....170@..140+..753....918....467.854....*................989..........979...............*.............-.907...276...931*618.........
..700............................................801....929..859.....#..........*.............594.493......981..........*...................
....+............173..............................................251........629..........970........*................136.........388...*...
......721.......$......911....766..................541.234....=...........47......614....@.....*217..885.680.742....................#..84...
.377*....*81.............*.......&...937...........+...*....155..@......*............*......648............&...*.....&401......493..........
.....1.................533............*..399...........861......951..709.331..126.....876.....................289.........@.....*.......*...
..........107....452-......594.888.431....*..+660...........79................................$......275*876.......978.....594..400...39....
.........+................*....*.........925..........$.......*........599.......228..........60....................+....#..................
...283...................177...708...........642....661........294........*............................288*793.867.....482.479.769....73....
...........617..855*...&.............605................783.91.........847................&...../...............*..#..........*.......+.....
.672..303+...*........967...............*453.....884@......*...208.949........*..........986.....249.....352..818.596.56....................
...*..........88...............569.....................975.....*.....*..638....619.......................+.............*.......*.......462..
....500.....=...................*.................*205..*..-...228.508....&........................395..............845.....683.365....*....
........197.672.841..............214.=...847...912.....24.349...................%....584.257............152.................................
.626....-..........*..447............714....&.....................463....287...360........*............*...............*.................717
..........53......334...*........................*167......................*.......................554..246...........295.396......./.......
.......24..............92...........897.......220...........................930..703...414.....711..*.........723.........*....117...146....
.......&...........548.....324.21......................622.........820.404...............*....../..139......&......*.......578...*..........
.....*......204......*..........*.............226...........663.......*......555.992.....502...........631..49.#....366........677..........
..958.350.....*......44...694...449..-39........*...........-...786.........*......*............................140.........................
...............477.........*...................815..............*..........815.................521....................&...273........103....
.........828............781....464..................276......646....665-............924..........*.......955........759.........934...#.....
........*..........*..........*..........15.193.......*.....................&.................808....347*......963........*....+............
.........810.....360........638...434.....*....*751....812.....573...........85.........+.........95.......892...*...153...220..........187.
....714*....................................................80*....162=.................214...........842...&...39..........................
........265.........................51.......285$.......................586.......=.................................*.....*..............948
..989..........22.=......374.......%....................142.......736..@.....507.636.797.....273.........872.....567.978..334.....382...*...
..........@.......68..=......................116.130.......%.250../......-...=........*.........*486.415..........................*....813..
.......505............61..140..........435..........*691......*........852..........571....408..............12......80.......228...109......
.........................*.........207...*..24................402.=...........................@....................../...162................
....285.................672.552........492....$./..................3..620.391...............................179............*................
...*..........159...428.......*.................390.111.........$.....*...*..................348.355.481.......&.210..99...41...............
...52......12..@..........808.810.897...................663..280....57..............476.............*............*.....*........208=........
..........*...............*.........@.286..................*...........................*..........................905.296..............148..
.......298......119.....172.................622$..637................#......342.......679.111......-968..104*478............#.......*.......
.../.............*........../......................*..............658..........*718..........*136.....................503.899....889.498....
....691........341.262..36.549...........386........437.............................662...........848............#......*...................
.......................*..........936...*...............................-...........*......516....%......358....707..535...........841......
......$..............639............*..798.../..67%............137...716.......313.247......................-............@.....371..........
....433.677..605.267................1.......930........478........*........565*................................869.......372..@....228......
...........@..*..$...794.........................74.......#./......833.348.......................................+................*.........
......865...............*.........................*..........839.....................=......................................916..84.@.......
.................-....451........541@......468..684....18............759.............499................124.....426*.........*......882.....
...68*...........614........509...............*.........&...956*308.%........&....36...........480+....../..........917....32....#..........
......363..377.............*..........441.....418..........................279.....*.................139..........................944.......
........................412............*..........%....920*585....526*............931.346&.807..840.....*.626-...#....................923...
.....283.....924...+..................628.......33....................908..766..............*........336..........446...........191.........
...............*.249........@264..35...................502.791.#...........*......=............126....................957....71....*.768....
.........144&.36.....216.........*...........................&.730..........201..581.704.........$......715.............=......*.......%....
...349..............*....598...949.........189....981.....#.............524...................*............=................440...847.......
.................967....#..........999*6..%.........-......604............&.189.626...#774.159.647....................168.........../...329.
..............................................481.....*........................*.................................747..%.................#...
..........245...878.......495....57....841.........351.517..........-297........................343.599/........&.......360..........-......
430........&..............&.....*...&.....*885...........................9....392.......93..336*...........................*321.....86......
....469......#.................999..796..................899.........250*........$.......*........247............................+.......328
......*...696...615..300..603..............................*....232...................402...501......*.......77.271.....@.........146.......
......170......%....$.........*..991..........782.49.......128.............................*........161........*.....648......123...........
..........646................901..*.............*......134...........517..2..287........513...............................644...*...........
...................999*620.........541.379.....488..18*.......................*...............208....931.338..%143...........*...19.........
...+.......938...........................*...%.............&........626......268.418......841*..........*...............820.395..........913
.723...834*..........+............162.667.....84............803.804...*............*................399........172..530*....................
.....................596............*............................./.287............852....623....@.*..............@........168...965..*17...
.....=488...................758....607.....&......53%......................105.683......-...*.860..244.....&....$....232....................
.............................*..........333....................197........+....*......334.954.............686...464...............544.......
.139=..............754...993.677..../.......933..........391....*....357*.....952......................@..........................*.........
..........831............../.........94.600................+.121.........183........18..686.....665*..823...........575...........68........
141...800....*....692...........254@.....*...819-.....................................*..@...................17.......*...815...........686.
........%.602........%.................186..........562.93....774.....................11....948....912.........*328..243.*..................
.......................................................*..........607....280..................&....+.....................548.&897.100@...955
......504.....605...........889@.............975..664....$.....#............*....141.................378%.........812.......................
.....=...........*.....730...............%...............899..480.....*....375.....-.444.........47*.........@63...........828.....468..462.
.......607.../...23....=......=........383.............................522............*.............433..360..................*372...*......
........*...975.............428...................592*......@258...114......%......431...................*......+........658.......560.163..
........16........................329.......315.......973............*...333....@.......$....782..18...58....533........*...............*...
..327.............563...889.......*...........*..595...............913........671..354..937...%..*...&...........&.787...975.......676...247
.....+..&...401..*..............713........=.757...#.873*47...#465..................................440..588/..859.%..................*.....
.665....133...%..196....907..............348..................................162........305...................................163.-........
....*....................*...........170.........222.804....784..............*...................................................=.742......
..239..338.....27-.437..543.........*....609......*..*......-...............582..-...........343*560....852.../....636..263.................
..........*900.......*............17...........948.....597.....=....922...........682./255................@..35.......*.......211-..#.......
.......*...........686........984..........78......896*......13........+....................985...&....................278.........876.835..
....630.82....$851.....905.......*..281...*...............................352..........*746........215.877....845..........471.852.....*....
.........................*.....757.*......625...........924......878..........912...............-.........*../.....538%......+.........871..
..954*712..977.....-..762..........236.........527*674.*.........*........811*.....228....&.....5........739...483..........................
..........*.......470..................................707....363.................*......525.......303..........*........463....537.........
...460...947...............130.....757./96........*.................=...529....+..466........527................65..%648....=.....*.........
.....*......................$....../..............968..............479.&....630............................598.................952..........
.......&..........793...................................514...............-...................311..........=....83......#.............124...
.975....399.......*...-.......*814...663..................*....*...........381../...............*.............@.........284............*....
...*............367....198..........@.....992.....716*529....96.................729.329.688...%.322.-......67.79......-.......335....997....
488............................632........*...../......................387.............*....225......491.............391..750...%...........
.......861.527......778.165.......*........187..916.......845....-....*.......873.................................@.........................
..545.....*.....$.....*..*......627............................736.376..845...*....594........+.......171.........292...........*750..-.....
.................407.403............+...342.................+..........*.......897..........400.......$......................910.......350..
...........................40..284.66...*......494..........255.......653..............866.................942=..................*52........
....&........827.......296...*........$.401......*..............892*...................$.............1.164.......343..........485...........
.930............*.........*..944...308...........763....../.........62.....113....=...........421........*..........................580+....
........50*.....934......705............................999..................*....541...............847-.950..............*131..............
...........209....................................&404...............276..242.............723.652................873...313..............24..
......*........606....550#.....2./........@..................899.......*.....................*..........235..112...........704.....337......
.......837....*...............*...83...993.....*416.........-....580%..535......../.....-204...............#..*.....93+....*...723./........
..............168.....753..593..............504......./........................488..............=.............458.......872...*.............
...#85...................&......911/...................880........315..872..........=....494..349....466..428..................40...........
........939........648......................*................227...*......*.......924...*...........*.....*.................................
918*......&.@........*...902..269..834....87.826.........../...*...919.118...817......109..........933..643...........&..............-......
....949......883...111..%......*...%..................710.464.943.........../...................................842....305.....469..289.....
..........................%...974......*407..168.647...*..............617.......498/.....848...........@99........*...........+.............
..........176...........120.........469........&...#....997......464.......274.............*......./............477.417../.......738........
.........*.......964.........291..........................................-.............2..29...272..465...............-..819........718*265
....298...747.......#.......*.....+745...........460...741*762.275...491.......+.735*34.*............-....*841......+............*..........
...*........................593..............298...#............%....$......225.........943........................23.....702.601.616.......
..889................695........654..750.....*.............637........./...............................780....*726....233...*...............
..................../.................*.....453.....642....*.........828......@...94...........152/...*....790.......*.....445......../.....
...........................51.......681........................271..........719.......................964......399..426...............456...
+78
View File
@@ -0,0 +1,78 @@
import re
def main():
with open("3-input.txt", 'r') as file:
lines = file.readlines()
total = 0
for line_index, line in enumerate(lines):
print(f"Line: {line_index + 1}")
digit = ""
for index, char in enumerate(line):
if char == '*' :
nr = []
print(f"found *")
for i in get_number(line, index-1, index +1):
print(f"found {i} on same row")
nr.append(i)
if(line_index - 1 >= 0):
for i in get_number(lines[line_index - 1], index-1, index +1):
print(f"found {i} on above row")
nr.append(i)
if(line_index + 1 < len(lines)):
for i in get_number(lines[line_index + 1], index-1, index +1):
print(f"found {i} on lower row")
nr.append(i)
if len(nr) == 2:
total += int(nr[0]) * int(nr[1])
print(total)
def get_number(line: str, from_index: int, to_index: int):
res = find_digits_with_index(line)
numbers = []
for seq, idx in res:
if ranges_intersect(range(idx, idx + len(seq) - 1), range(from_index, to_index)): numbers.append(seq)
return numbers
def find_digits_with_index(input_string):
pattern = re.compile(r'(\d+)')
matches = pattern.finditer(input_string)
result = [(match.group(), match.start()) for match in matches]
return result
def ranges_intersect(range1:range, range2:range):
# Check if either range's start is within the other range
if range1.start <= range2.stop and range2.start <= range1.stop:
return True
else:
return False
# titta i en line från index -> index
def has_symbol(line: [], from_index: int, to_index: int):
if from_index < 0: from_index = 0
for i, char in enumerate(line[from_index:]):
if(i + from_index > to_index):
return False
if(not notDigit(char)):
return False
if(isSymbol(char)):
return True
return False
def isPartNumber(line: [], first_index: int, last_index: int):
is_match = False
if(first_index > 0):
is_match = isSymbol(line[first_index])
return is_match or (last_index < len(line) and isSymbol(line[last_index]))
def isSymbol(s: str):
pattern = r'[^0-9.\n]'
return re.match(pattern, s)
def notDigit(s: str):
match = re.findall("\d", s)
return len(match) == 0
if __name__ == "__main__":
main()
+3
View File
@@ -0,0 +1,3 @@
416.........................559...............417...............785.......900.......284...........503...796....992..........................
.........702*....772............378..569.........&.49..606...14*..............$.453*.........307....*......$.....-.................995......
.....................458...856......+.........+....&..............680.......104.............%....516.................................*......
+186
View File
@@ -0,0 +1,186 @@
Card 1: 10 5 11 65 27 43 44 29 24 69 | 65 66 18 14 17 97 95 34 38 23 10 25 22 15 87 9 28 43 4 71 89 20 72 5 6
Card 2: 25 43 15 31 45 19 36 73 34 85 | 92 11 85 68 74 20 19 71 1 36 43 32 77 33 14 31 73 15 45 83 34 25 6 88 57
Card 3: 4 46 42 23 18 98 59 75 19 57 | 22 3 75 80 42 23 59 39 98 38 18 21 67 57 20 25 71 26 64 4 83 79 91 65 90
Card 4: 92 13 56 27 19 44 70 93 32 66 | 38 4 19 75 87 93 32 1 23 14 51 22 42 44 33 63 13 56 70 66 18 92 47 53 27
Card 5: 25 18 30 45 23 80 91 13 47 61 | 62 45 71 30 39 19 61 68 23 80 91 96 25 58 13 88 67 29 60 2 74 55 12 83 46
Card 6: 20 36 26 18 61 35 94 58 79 19 | 85 68 56 7 53 58 19 20 79 59 26 61 18 15 94 33 29 71 35 89 17 36 3 67 72
Card 7: 29 21 71 91 74 6 12 53 50 55 | 29 51 12 74 82 18 21 55 53 33 65 91 95 69 2 62 57 50 3 79 71 61 47 6 14
Card 8: 24 72 46 88 65 12 48 97 76 73 | 17 97 87 18 83 11 49 44 88 79 64 55 19 25 63 74 73 14 82 15 72 43 76 48 46
Card 9: 86 38 55 52 33 61 41 75 87 26 | 38 97 88 91 33 36 54 64 40 52 68 71 43 55 72 75 4 61 58 49 56 86 30 15 17
Card 10: 15 37 72 5 66 81 33 6 80 76 | 52 34 21 68 72 82 91 81 7 19 86 67 94 87 16 63 43 9 14 23 44 60 18 4 74
Card 11: 24 21 17 27 34 80 18 79 56 32 | 18 45 21 63 82 69 48 54 89 5 83 80 92 93 49 8 55 12 97 35 4 3 42 94 56
Card 12: 90 61 45 54 64 93 69 85 58 88 | 79 89 74 45 27 61 9 56 69 88 13 80 66 4 16 62 34 51 71 54 48 64 58 63 50
Card 13: 80 39 35 27 56 94 25 77 84 26 | 24 19 72 54 96 63 56 15 25 16 59 35 20 57 52 65 95 66 45 31 77 60 42 93 37
Card 14: 33 83 94 41 7 79 18 40 24 97 | 49 27 45 21 20 8 93 26 12 42 94 33 96 57 98 91 19 52 78 2 18 80 65 72 44
Card 15: 16 83 92 40 13 35 94 23 47 17 | 55 61 75 43 18 5 22 65 67 7 49 63 71 13 45 78 53 21 57 34 98 99 64 32 56
Card 16: 14 76 72 8 42 61 60 82 24 21 | 56 10 38 11 37 45 29 22 51 98 86 49 26 13 16 52 50 14 70 30 87 73 66 77 88
Card 17: 63 32 83 13 81 89 33 49 5 34 | 99 85 12 6 27 93 78 44 14 76 1 51 36 9 4 62 91 84 8 37 45 66 75 42 40
Card 18: 43 97 37 61 69 94 60 67 91 99 | 87 25 65 98 26 62 42 11 61 32 34 76 14 20 44 92 22 5 12 46 21 33 3 15 59
Card 19: 32 96 10 49 26 86 67 85 50 75 | 58 98 84 43 23 33 64 74 37 80 63 40 51 95 13 55 31 25 87 97 81 52 53 24 6
Card 20: 7 70 41 40 16 15 20 72 47 93 | 93 41 7 79 62 86 69 70 75 67 51 72 81 15 22 48 47 80 71 38 40 97 20 82 16
Card 21: 90 76 52 48 36 37 89 45 20 17 | 23 48 86 7 99 50 20 58 93 43 16 91 5 76 52 45 17 68 89 22 61 36 90 37 83
Card 22: 85 71 20 58 32 83 53 94 61 80 | 88 59 66 80 49 53 19 97 5 20 62 8 94 54 67 73 93 12 10 61 32 41 71 72 85
Card 23: 60 61 30 65 11 28 89 54 22 78 | 88 71 97 46 60 45 54 26 22 42 59 57 80 9 69 61 47 3 85 7 32 78 11 66 33
Card 24: 35 16 5 85 87 58 66 39 88 12 | 51 32 59 41 73 21 58 79 72 10 74 28 95 69 16 92 88 18 34 46 77 17 65 76 99
Card 25: 67 41 62 96 40 22 81 12 98 9 | 92 66 87 35 50 38 19 14 74 93 1 76 59 6 84 99 58 61 34 13 63 30 53 90 24
Card 26: 10 78 28 1 72 94 60 71 37 89 | 71 9 28 11 4 72 43 90 74 37 18 14 40 16 21 97 59 13 73 89 63 60 5 10 70
Card 27: 65 7 45 59 32 51 22 16 2 64 | 65 37 72 7 26 86 49 3 63 67 16 52 51 21 89 14 70 78 36 27 92 39 8 64 42
Card 28: 89 17 93 57 78 33 52 97 53 4 | 23 20 66 55 42 28 52 61 35 41 60 51 84 83 49 67 22 5 48 9 2 7 87 38 93
Card 29: 64 12 30 16 87 59 76 34 85 28 | 47 21 32 37 94 25 6 26 49 59 81 45 87 70 23 5 91 8 34 58 72 89 52 93 63
Card 30: 11 69 86 19 59 28 41 68 81 66 | 92 33 1 43 88 75 42 29 38 55 24 89 4 95 47 70 30 65 83 72 25 82 14 85 21
Card 31: 48 43 14 54 80 70 93 64 42 77 | 91 19 62 79 30 23 29 11 37 13 41 54 97 52 7 90 33 17 96 28 20 9 47 31 38
Card 32: 78 91 2 56 93 3 88 50 20 12 | 2 20 18 84 12 82 43 76 39 53 32 79 57 17 63 28 30 9 1 55 96 70 29 25 87
Card 33: 99 93 14 28 36 68 11 97 58 9 | 94 4 67 66 40 87 96 83 78 23 71 41 92 24 77 1 15 42 12 57 3 89 46 72 59
Card 34: 20 88 61 67 31 21 90 30 26 56 | 6 71 18 34 66 10 41 37 58 32 13 76 3 96 86 47 50 91 17 15 39 68 73 27 12
Card 35: 5 58 96 48 47 70 19 34 63 84 | 21 59 88 32 37 33 20 49 55 62 7 66 1 2 40 77 22 82 39 13 45 61 56 44 17
Card 36: 36 66 44 13 33 2 60 46 4 31 | 73 99 13 72 44 80 60 77 65 19 46 4 59 97 61 98 31 92 83 2 68 36 66 33 22
Card 37: 95 71 87 60 17 19 97 30 48 55 | 30 53 35 19 94 27 95 44 47 13 69 87 12 56 4 26 85 17 63 7 70 60 71 41 3
Card 38: 61 16 20 92 98 19 79 62 45 91 | 79 44 60 23 25 83 92 19 16 38 66 48 75 20 2 98 24 87 45 62 61 32 91 69 13
Card 39: 49 2 18 74 99 30 54 16 93 68 | 8 74 75 72 68 67 89 86 31 30 97 47 24 71 18 99 54 22 16 70 3 7 49 50 25
Card 40: 12 45 7 15 65 84 77 36 28 1 | 51 35 63 43 59 81 88 58 56 71 94 46 9 86 28 13 30 99 20 17 95 23 32 54 47
Card 41: 8 99 26 60 56 69 48 47 31 16 | 83 9 66 73 95 67 21 86 94 2 99 51 98 80 57 36 82 4 23 19 12 68 88 44 59
Card 42: 99 48 94 50 91 55 2 12 67 36 | 47 45 62 66 31 84 26 20 52 41 40 55 21 35 37 15 69 53 72 65 79 60 25 48 57
Card 43: 41 75 61 39 67 88 48 42 51 79 | 85 99 95 79 64 92 34 8 46 15 56 28 12 6 81 48 41 49 20 97 91 67 51 55 74
Card 44: 10 99 33 96 21 6 49 62 82 38 | 68 41 88 24 6 28 98 66 96 49 30 33 94 85 1 75 21 61 60 99 89 81 31 54 20
Card 45: 46 61 60 2 29 45 7 55 83 16 | 25 34 84 91 97 61 55 17 16 79 67 53 59 27 69 58 29 46 24 93 3 32 60 49 33
Card 46: 93 25 42 68 22 85 58 61 63 50 | 8 46 4 15 96 83 94 13 19 65 24 80 64 38 89 44 52 78 98 36 47 51 97 2 57
Card 47: 11 59 80 10 72 76 43 86 56 7 | 59 67 35 5 47 81 99 21 38 90 73 55 64 24 34 42 58 51 56 11 68 60 23 92 43
Card 48: 97 88 28 44 24 10 17 27 83 12 | 67 92 74 50 4 35 77 47 6 40 11 20 76 16 42 9 3 79 68 82 43 41 60 94 89
Card 49: 35 98 90 92 42 12 13 83 53 95 | 36 34 51 96 24 94 53 7 31 6 71 48 16 75 77 83 68 46 14 66 65 22 9 74 93
Card 50: 1 65 66 2 76 36 78 56 99 90 | 12 13 3 38 96 20 10 14 57 81 7 35 88 55 68 48 31 52 89 9 70 15 79 80 16
Card 51: 70 41 53 40 55 82 69 7 5 71 | 56 4 54 46 65 17 91 94 72 88 90 31 85 14 97 95 44 26 92 8 21 73 38 77 37
Card 52: 62 16 85 42 56 1 82 92 43 37 | 74 28 19 42 82 21 85 37 75 50 17 16 1 76 56 86 91 31 3 92 6 62 43 64 83
Card 53: 69 91 12 9 63 50 58 57 67 13 | 40 42 70 62 6 69 9 82 78 19 89 56 57 83 47 25 98 46 30 53 72 28 10 58 44
Card 54: 73 44 64 21 16 50 63 41 36 51 | 6 4 66 39 21 14 67 50 15 1 35 40 64 44 24 73 28 47 80 13 2 43 91 46 16
Card 55: 47 55 14 43 1 54 81 65 19 33 | 19 10 97 44 84 61 5 25 96 81 32 73 75 83 65 17 3 41 14 92 9 80 27 63 8
Card 56: 43 26 93 75 33 51 89 60 1 81 | 9 10 16 60 84 81 93 26 4 96 17 91 79 18 43 67 47 92 1 33 21 63 51 75 89
Card 57: 76 70 7 31 8 39 63 99 30 13 | 31 63 76 17 68 39 30 50 27 72 84 79 70 57 28 13 29 97 67 8 75 87 3 7 99
Card 58: 28 29 86 65 7 36 38 3 20 43 | 70 20 65 64 43 98 18 19 78 87 7 55 30 35 28 37 56 29 39 38 3 40 36 86 75
Card 59: 55 10 23 31 17 37 22 92 14 44 | 67 11 60 92 42 68 44 78 3 43 76 16 97 55 8 35 49 54 18 40 46 52 95 84 69
Card 60: 34 13 63 27 44 11 80 9 43 28 | 48 44 95 59 41 13 30 40 73 33 10 19 74 14 78 12 37 28 35 63 87 39 53 11 93
Card 61: 42 75 7 20 73 47 16 28 5 92 | 12 65 7 5 38 74 58 28 62 85 10 47 18 75 86 52 73 77 1 43 36 93 80 13 20
Card 62: 47 35 92 12 61 25 83 96 6 87 | 5 21 56 66 24 13 19 54 68 92 87 12 93 35 88 11 49 79 69 31 42 96 47 59 84
Card 63: 43 97 21 67 11 40 81 53 23 42 | 65 52 24 80 71 6 3 88 72 17 66 77 41 57 44 91 1 36 56 27 39 43 8 67 34
Card 64: 96 73 20 69 19 93 98 99 41 24 | 20 19 52 63 60 34 8 40 14 6 89 1 94 62 98 96 22 71 65 35 28 18 25 59 42
Card 65: 5 40 14 19 36 93 59 9 12 75 | 60 15 90 21 71 66 86 59 62 31 82 76 38 14 9 98 53 32 6 8 19 4 11 33 29
Card 66: 97 35 40 5 62 15 79 72 38 32 | 69 8 94 75 35 9 64 96 42 76 67 91 31 92 52 71 77 45 18 12 61 25 88 20 50
Card 67: 55 89 12 98 71 16 36 87 91 25 | 32 39 83 13 10 81 51 29 43 7 70 60 40 78 44 17 23 94 57 22 20 11 86 34 99
Card 68: 53 37 26 55 34 39 62 35 68 86 | 44 85 58 41 42 31 52 35 66 49 77 65 27 60 7 2 45 21 26 40 20 18 69 4 99
Card 69: 45 7 89 51 21 97 38 33 84 28 | 72 39 65 64 24 1 62 56 54 12 5 60 80 49 88 26 42 19 71 46 87 70 9 8 82
Card 70: 50 92 10 16 56 40 14 6 61 30 | 11 68 37 3 74 32 58 66 18 20 69 33 22 19 97 7 53 39 64 91 57 55 51 87 83
Card 71: 16 38 60 51 15 56 26 46 76 64 | 26 65 51 88 63 56 64 76 61 40 20 16 55 81 29 58 7 38 46 62 37 23 4 15 60
Card 72: 48 3 37 4 61 7 63 69 18 38 | 7 63 22 48 8 91 2 77 40 44 69 86 51 74 37 53 38 96 49 3 4 61 18 15 43
Card 73: 22 59 55 78 44 99 96 29 76 46 | 59 23 44 31 29 63 18 92 46 22 4 56 85 43 82 94 95 48 14 64 78 76 55 99 96
Card 74: 49 46 66 52 68 64 62 93 81 96 | 83 31 15 98 68 17 74 79 81 20 25 66 16 53 43 46 30 21 24 70 63 1 82 71 72
Card 75: 25 56 3 78 52 87 6 5 54 99 | 1 4 66 17 87 5 52 79 88 25 36 99 86 3 65 61 70 71 78 54 56 39 69 68 6
Card 76: 62 66 78 11 51 71 42 84 39 33 | 26 29 45 7 32 58 83 72 19 82 67 91 76 59 39 93 41 5 12 47 79 49 21 11 20
Card 77: 98 80 42 61 82 18 34 66 2 1 | 84 33 16 9 91 86 22 42 1 34 46 99 41 82 85 61 49 26 18 88 98 66 80 72 2
Card 78: 74 69 73 62 50 86 14 34 15 57 | 73 40 62 15 52 9 68 82 46 86 89 22 83 74 50 58 38 8 34 16 14 69 57 64 60
Card 79: 99 36 21 35 10 43 32 69 74 6 | 10 14 75 66 48 15 17 43 74 2 16 50 56 6 69 61 87 36 99 32 90 21 35 60 28
Card 80: 63 3 55 47 54 20 95 72 36 57 | 80 57 63 66 47 44 49 38 3 54 15 52 11 75 16 72 50 55 36 95 33 81 26 45 20
Card 81: 46 61 5 40 70 1 65 18 74 78 | 70 66 57 55 9 33 83 71 78 37 74 18 92 38 65 84 40 1 97 61 91 59 5 46 24
Card 82: 85 25 81 91 76 71 8 12 24 21 | 37 76 74 34 85 91 44 41 99 8 25 28 98 39 24 12 71 75 95 47 21 69 46 81 40
Card 83: 98 57 78 67 90 55 53 74 59 85 | 20 52 73 61 41 64 85 4 68 70 87 14 32 99 55 48 84 74 94 80 50 42 25 44 35
Card 84: 22 56 11 9 47 49 1 91 78 55 | 52 28 97 67 44 37 4 61 36 53 96 30 2 19 9 43 29 15 49 41 68 72 7 38 94
Card 85: 84 66 28 12 30 82 69 57 72 76 | 37 48 69 96 47 78 98 59 43 27 29 35 15 81 32 64 66 57 94 95 44 12 2 89 70
Card 86: 47 5 23 50 56 45 25 54 60 42 | 34 71 3 94 42 46 43 5 39 83 95 27 40 18 13 14 47 59 65 12 38 11 15 82 28
Card 87: 93 58 92 44 94 78 80 26 39 50 | 75 47 94 20 9 85 79 26 56 44 14 67 95 5 12 6 31 30 39 40 8 58 80 34 59
Card 88: 61 20 91 64 69 87 50 2 8 45 | 61 14 28 67 11 91 82 51 18 52 66 24 62 59 92 69 2 49 3 46 42 35 4 27 20
Card 89: 32 38 6 48 14 60 82 1 9 5 | 97 29 67 21 7 46 12 19 65 14 34 35 44 82 64 5 40 98 57 13 45 55 10 22 79
Card 90: 89 54 9 27 86 29 17 26 20 47 | 46 51 40 60 2 41 59 89 79 47 73 52 15 29 81 84 96 22 44 13 10 72 87 28 86
Card 91: 98 15 46 26 72 22 71 82 90 39 | 63 62 29 7 90 79 12 49 54 96 21 70 6 13 2 9 86 53 99 3 33 72 66 28 22
Card 92: 65 33 98 12 70 18 47 71 69 59 | 58 66 85 27 26 43 87 51 39 83 73 33 17 54 90 5 99 29 8 49 34 71 45 19 78
Card 93: 62 50 63 30 80 74 32 70 31 12 | 28 3 9 71 34 40 12 77 55 69 2 44 76 58 83 11 23 17 10 13 33 81 93 94 85
Card 94: 21 23 14 63 32 5 70 79 81 44 | 4 1 18 35 64 58 80 42 47 92 25 78 82 11 9 83 65 86 17 90 69 56 98 85 84
Card 95: 88 44 69 23 3 34 22 59 72 10 | 30 87 25 88 72 57 34 10 3 1 4 64 44 17 42 33 20 69 93 65 73 11 23 59 22
Card 96: 51 94 55 41 65 57 59 98 39 96 | 38 54 83 39 96 94 88 65 32 41 9 55 51 73 93 59 58 63 64 98 45 57 8 33 74
Card 97: 4 5 90 20 15 14 49 40 84 11 | 73 75 29 47 15 64 53 66 74 43 50 84 12 28 90 5 3 20 4 11 40 49 14 71 95
Card 98: 74 49 44 95 50 71 77 22 41 57 | 4 75 47 3 45 82 58 53 88 69 59 17 51 68 66 67 36 25 7 14 78 12 49 73 9
Card 99: 48 4 79 15 61 85 92 45 22 81 | 30 23 78 35 17 14 24 68 90 74 37 32 46 19 79 42 22 43 50 41 7 92 39 10 15
Card 100: 26 67 9 17 82 11 34 47 10 20 | 56 10 73 34 59 62 97 67 12 48 47 20 17 90 7 40 50 13 55 9 27 65 31 38 26
Card 101: 79 10 29 36 95 26 94 40 50 89 | 6 54 33 88 74 46 67 70 51 39 94 78 31 59 37 5 56 53 36 42 1 87 29 64 40
Card 102: 50 40 34 30 2 32 95 70 10 16 | 57 66 90 83 94 31 79 67 14 93 28 52 32 22 9 43 54 39 49 40 35 21 87 78 88
Card 103: 85 35 6 42 31 71 49 17 95 55 | 61 67 34 99 52 59 46 38 51 36 73 43 94 97 91 76 37 4 25 18 30 64 41 22 26
Card 104: 89 73 65 69 94 68 28 49 19 55 | 14 33 51 92 40 70 73 91 45 20 72 21 69 43 19 52 56 27 4 37 67 1 13 80 83
Card 105: 65 98 51 74 36 45 61 87 42 50 | 70 6 30 26 84 75 1 96 37 31 53 95 24 66 40 52 72 22 44 54 77 99 25 19 69
Card 106: 35 46 52 34 28 3 36 42 80 10 | 53 43 20 22 62 75 83 11 44 85 78 39 72 90 73 18 86 16 65 19 98 47 41 45 88
Card 107: 92 17 73 3 72 57 63 66 1 9 | 61 67 98 59 31 3 48 83 33 1 72 2 13 42 50 68 19 53 15 32 14 9 49 52 23
Card 108: 9 27 28 88 4 82 63 73 36 92 | 99 45 20 57 31 94 7 22 39 55 86 79 95 62 96 58 97 12 15 56 34 40 17 51 33
Card 109: 48 43 25 17 34 83 3 19 18 86 | 61 71 38 28 96 1 36 25 16 37 52 33 67 83 50 47 10 46 51 34 11 7 77 68 80
Card 110: 36 41 13 69 51 66 48 79 60 93 | 94 80 37 81 66 97 17 73 13 35 27 67 88 29 84 57 96 77 12 75 33 85 15 82 58
Card 111: 88 65 71 66 39 67 50 42 86 99 | 20 10 87 41 45 63 31 40 64 35 97 99 53 98 72 11 85 19 79 13 22 55 24 25 34
Card 112: 75 37 68 18 90 88 42 20 50 40 | 31 5 15 80 33 66 35 69 64 97 11 92 85 94 24 65 44 22 71 36 17 12 29 39 98
Card 113: 81 60 57 44 33 56 89 36 50 1 | 27 76 64 89 85 68 42 36 22 67 32 60 4 57 74 28 16 17 44 65 14 31 43 45 12
Card 114: 34 92 35 43 65 63 29 49 48 13 | 13 16 12 31 14 75 2 30 3 37 28 11 91 50 69 72 87 52 95 85 58 94 49 19 23
Card 115: 11 80 20 25 93 96 19 99 74 58 | 41 45 39 22 19 31 20 99 25 62 37 77 58 78 3 1 81 96 56 14 32 85 83 53 57
Card 116: 86 83 81 62 55 80 77 46 53 38 | 62 80 30 83 70 54 38 51 25 46 84 81 27 53 58 55 56 41 9 77 22 49 18 86 78
Card 117: 25 95 92 2 7 30 81 76 96 61 | 12 52 25 2 34 92 82 58 96 85 76 67 70 81 16 61 7 19 37 95 18 43 45 79 30
Card 118: 91 45 52 34 15 28 48 83 67 38 | 98 6 92 67 38 79 34 4 80 48 58 91 88 72 3 33 52 73 45 89 28 63 41 54 17
Card 119: 71 82 4 62 58 44 60 34 79 14 | 40 62 82 60 58 34 3 27 22 14 72 65 4 85 53 96 7 46 11 97 35 47 67 19 71
Card 120: 63 80 9 4 94 46 66 61 81 76 | 47 35 81 21 73 23 63 38 55 65 94 76 54 15 87 43 8 72 70 75 9 3 66 80 85
Card 121: 67 50 91 52 64 43 30 75 34 85 | 95 32 8 64 43 42 85 45 98 76 7 52 80 22 46 9 36 30 15 40 54 81 44 67 57
Card 122: 19 62 83 56 46 1 47 64 25 23 | 67 50 30 79 58 90 39 80 69 20 91 37 94 65 88 98 18 92 73 33 66 44 70 11 64
Card 123: 87 36 39 75 4 6 85 9 54 82 | 44 50 45 57 27 34 86 21 97 53 93 75 39 26 61 41 81 49 51 29 13 66 37 30 87
Card 124: 74 32 61 26 52 21 3 30 5 58 | 38 69 20 31 68 60 44 61 97 79 29 66 23 62 37 94 33 54 96 71 87 1 9 50 11
Card 125: 99 26 61 20 66 13 40 62 89 29 | 66 3 60 19 8 43 48 28 70 23 45 35 64 5 42 58 95 15 56 59 44 1 51 49 80
Card 126: 51 1 62 49 98 34 36 74 73 17 | 67 92 29 10 21 59 91 89 11 15 83 9 63 99 41 60 31 73 78 25 72 96 35 87 71
Card 127: 90 94 39 24 60 8 53 14 78 27 | 54 51 77 16 1 67 6 20 15 18 71 41 81 10 66 63 13 11 64 4 58 43 83 65 98
Card 128: 43 40 76 96 65 82 15 5 23 16 | 70 24 56 40 52 71 96 7 87 91 11 75 43 41 5 45 30 33 34 15 80 27 61 76 17
Card 129: 90 76 62 9 60 2 48 87 80 52 | 10 7 96 17 8 71 47 52 59 91 1 4 33 56 58 66 92 2 37 53 9 29 25 98 13
Card 130: 88 44 46 35 38 33 86 60 40 83 | 86 92 43 88 40 26 80 4 11 54 46 44 50 60 58 33 35 83 82 48 67 18 55 89 38
Card 131: 54 34 30 7 66 16 81 71 98 9 | 57 65 78 81 98 24 34 88 96 69 7 54 41 53 63 30 52 8 71 66 59 16 9 79 11
Card 132: 51 40 52 69 64 83 5 39 2 58 | 58 5 88 83 93 56 78 50 40 63 39 62 89 52 75 81 6 43 65 55 69 2 64 33 51
Card 133: 34 96 6 68 85 44 60 66 3 64 | 67 60 64 82 53 85 55 99 44 34 6 68 66 92 70 84 3 45 88 19 78 24 74 96 49
Card 134: 60 85 79 76 9 68 49 67 5 44 | 79 2 68 59 76 14 3 96 67 13 7 73 88 4 77 71 43 44 11 5 27 95 60 80 20
Card 135: 24 84 80 20 88 19 73 22 74 56 | 67 3 13 94 50 6 8 98 87 68 17 82 99 77 14 32 23 72 93 95 60 53 41 48 51
Card 136: 40 21 95 86 63 78 61 49 14 67 | 92 84 85 79 55 56 96 52 34 22 57 26 65 93 43 5 50 8 36 94 46 30 97 64 80
Card 137: 89 69 19 24 83 11 97 42 18 9 | 43 38 89 82 75 14 9 58 24 29 4 19 46 42 11 2 23 97 67 17 18 69 83 81 16
Card 138: 70 72 41 78 17 85 93 97 99 73 | 11 93 97 81 52 17 49 10 91 20 99 58 13 89 74 47 70 23 65 90 7 4 64 28 85
Card 139: 18 38 96 48 37 73 80 89 7 19 | 77 13 3 51 4 45 76 21 93 33 43 47 57 17 24 11 35 75 59 60 44 5 90 55 32
Card 140: 52 2 39 85 65 97 5 87 20 90 | 42 26 34 60 65 50 90 94 23 84 73 16 89 37 79 3 17 55 33 14 9 98 70 96 56
Card 141: 85 56 58 55 62 47 92 76 95 89 | 41 58 67 78 4 61 10 17 23 1 50 21 18 90 45 94 15 37 48 31 91 54 73 35 64
Card 142: 71 70 76 83 96 52 33 66 6 50 | 16 82 5 21 55 80 51 52 72 65 1 86 15 11 54 57 77 70 59 18 48 12 78 67 25
Card 143: 89 67 6 13 59 12 81 61 57 25 | 27 37 13 70 68 52 82 2 74 50 92 5 85 78 93 95 34 91 87 36 55 39 32 8 48
Card 144: 69 50 46 63 88 9 7 20 49 79 | 5 91 95 71 86 32 66 76 56 33 96 15 42 22 34 27 6 67 43 19 36 23 63 20 75
Card 145: 69 23 76 4 13 41 50 78 17 60 | 16 57 68 43 34 11 18 66 72 7 82 5 19 91 61 36 70 15 87 59 65 21 67 2 8
Card 146: 27 79 9 28 56 36 48 31 20 6 | 78 94 48 1 97 12 99 19 74 47 30 98 14 70 44 23 35 42 73 60 17 29 89 58 95
Card 147: 46 80 82 8 50 77 28 85 38 41 | 27 42 57 31 45 76 67 53 13 94 68 90 89 16 11 35 51 92 10 66 63 52 6 83 65
Card 148: 80 44 24 98 26 78 4 1 55 88 | 53 8 55 79 86 16 77 93 88 58 23 44 64 73 11 83 24 29 26 74 13 40 21 62 9
Card 149: 81 29 26 20 92 62 50 49 69 74 | 10 26 69 96 27 74 44 70 32 31 8 95 25 90 3 89 35 1 40 20 49 29 58 59 80
Card 150: 32 43 16 36 73 18 22 30 63 38 | 38 91 18 45 67 22 96 32 71 5 95 93 28 69 33 34 14 72 36 11 35 83 43 70 30
Card 151: 65 61 49 29 51 72 96 71 37 94 | 33 42 51 94 62 91 29 96 61 35 92 37 30 8 24 77 72 58 23 64 65 73 49 46 71
Card 152: 32 35 90 5 81 84 76 63 41 52 | 11 76 29 77 81 80 4 18 16 88 90 98 41 35 43 84 28 52 63 1 65 5 72 32 56
Card 153: 13 34 18 11 77 61 94 88 7 90 | 46 25 17 93 5 43 72 28 69 1 14 55 66 63 53 62 26 68 13 37 70 78 65 34 16
Card 154: 74 84 32 51 5 93 4 13 87 83 | 85 62 75 36 10 43 68 47 90 79 6 66 26 67 34 60 65 1 25 81 98 91 16 28 82
Card 155: 60 7 42 76 1 18 29 93 19 83 | 49 97 62 78 15 99 71 94 25 41 28 4 51 6 3 80 87 81 75 12 26 89 91 2 17
Card 156: 95 57 27 1 97 33 50 38 22 64 | 38 65 67 27 85 57 3 97 60 21 34 79 20 89 86 22 13 8 64 50 11 39 41 12 2
Card 157: 59 52 71 70 92 48 42 17 75 79 | 86 75 5 68 16 55 72 70 94 60 6 1 79 31 42 61 59 38 52 97 92 53 81 67 17
Card 158: 31 58 68 7 24 18 30 32 19 92 | 57 2 92 33 60 84 76 51 79 31 42 99 81 3 88 17 47 67 48 13 6 28 20 23 56
Card 159: 13 42 26 92 53 33 44 45 19 90 | 59 95 2 51 25 81 17 30 3 71 36 22 58 90 33 52 8 92 37 6 11 19 45 96 88
Card 160: 94 76 70 63 43 53 59 19 20 64 | 5 68 35 74 79 19 62 40 33 11 63 69 60 24 1 85 96 55 91 70 10 12 71 50 42
Card 161: 34 29 98 99 81 52 96 77 57 39 | 78 96 67 3 5 20 85 10 58 79 45 62 46 92 15 97 88 2 57 40 81 74 69 61 32
Card 162: 38 24 86 51 80 1 16 83 58 34 | 77 58 45 18 80 39 31 23 11 13 46 28 65 62 60 33 20 6 10 99 37 35 40 91 64
Card 163: 14 97 5 33 34 96 50 47 55 74 | 6 66 77 79 37 45 39 82 90 9 50 38 14 31 19 13 29 15 89 30 17 88 12 44 53
Card 164: 56 31 76 6 69 27 65 74 39 49 | 4 89 2 75 20 12 53 73 14 40 86 24 82 11 88 90 57 22 35 54 30 64 15 32 41
Card 165: 62 75 48 65 43 85 8 80 45 91 | 84 74 86 98 57 38 69 78 28 22 7 19 83 60 3 55 23 34 94 13 2 58 90 11 39
Card 166: 17 21 56 71 10 84 50 83 25 61 | 39 83 68 27 43 4 15 10 21 25 54 7 17 29 14 28 56 64 24 58 33 62 44 22 48
Card 167: 24 89 68 2 90 36 25 82 38 59 | 28 24 83 43 46 7 56 2 38 89 6 61 59 31 50 68 32 25 36 9 88 19 82 90 14
Card 168: 58 22 65 47 99 85 72 29 25 12 | 11 21 39 51 26 77 2 31 99 33 15 95 4 62 69 22 38 50 97 20 55 72 8 12 89
Card 169: 99 18 97 9 10 76 72 75 26 87 | 44 94 63 21 54 96 19 8 50 9 86 16 49 41 60 5 57 7 38 27 95 12 40 85 1
Card 170: 43 35 76 13 27 60 70 54 23 83 | 46 56 59 54 62 70 76 29 23 83 13 27 68 15 11 7 60 4 28 43 61 33 35 47 99
Card 171: 27 58 57 48 76 97 1 86 25 40 | 36 32 61 74 82 31 38 79 33 34 46 2 27 89 50 10 22 55 72 91 39 64 43 98 42
Card 172: 12 13 84 55 27 67 10 78 11 16 | 24 9 11 96 12 60 46 6 76 31 85 49 53 8 64 74 65 15 18 90 82 67 16 57 73
Card 173: 60 84 36 23 82 27 14 54 74 9 | 9 37 31 62 91 14 74 13 39 38 23 87 1 84 80 92 30 54 32 60 36 48 61 82 27
Card 174: 25 21 34 45 32 86 99 42 72 98 | 95 34 91 32 25 86 98 21 80 75 84 70 7 99 72 45 17 40 79 63 1 19 61 42 87
Card 175: 83 24 18 84 45 38 23 42 56 14 | 14 76 98 92 46 44 97 20 13 64 72 96 16 68 57 21 6 34 3 19 55 89 9 83 1
Card 176: 25 71 31 38 3 55 96 76 6 69 | 63 66 19 98 27 87 96 8 54 31 67 46 53 33 28 12 99 88 80 17 13 71 93 14 1
Card 177: 38 25 67 43 18 3 16 72 57 51 | 79 52 12 72 23 56 77 80 31 42 18 99 83 60 24 33 64 32 75 85 9 90 43 8 1
Card 178: 39 62 57 1 11 79 8 99 56 52 | 20 81 94 41 95 1 39 82 5 97 7 68 24 64 99 98 67 53 9 86 33 43 17 46 88
Card 179: 19 63 34 49 71 38 94 17 1 33 | 86 35 94 70 38 10 33 99 54 2 39 11 92 91 34 43 67 18 12 15 95 1 23 20 49
Card 180: 45 81 55 44 80 73 7 25 31 59 | 83 93 49 20 72 29 92 35 91 89 52 70 27 75 48 33 21 41 46 74 56 4 6 87 36
Card 181: 42 34 76 85 33 27 66 79 58 73 | 80 71 26 6 41 39 68 36 15 19 13 33 34 62 82 88 10 3 76 46 51 99 78 85 72
Card 182: 68 80 84 58 75 67 44 92 18 65 | 34 89 9 87 40 88 72 73 33 74 11 6 69 4 63 70 86 2 7 82 66 81 24 77 22
Card 183: 60 22 7 19 93 32 31 23 36 41 | 6 35 77 49 29 45 39 21 57 61 22 15 70 48 94 53 31 18 87 99 52 3 62 67 33
Card 184: 95 26 39 98 51 33 67 43 59 11 | 19 44 30 10 18 47 57 95 25 78 53 61 2 87 88 22 37 45 75 83 29 34 48 97 84
Card 185: 7 16 46 63 13 2 99 9 93 26 | 37 28 50 41 55 75 73 6 96 82 17 92 87 10 49 72 15 86 64 36 95 32 13 5 53
Card 186: 14 21 68 8 64 78 15 89 19 59 | 43 22 10 85 63 60 90 62 97 17 33 39 7 6 58 51 47 54 11 50 36 2 31 46 34
+50
View File
@@ -0,0 +1,50 @@
import re
class T:
def __init__(self, id, winning, card):
self.id = id
self.winning = winning
self.card = card
self.instances = 1
self.intersect = len((list)(set(winning) & set(card)))
def addInstance(self):
self.instances += 1
def main():
with open("4-input.txt", 'r') as file:
array = []
for line in file:
array.append(parseLine(line))
for i, card in enumerate(array):
for ii in range(0, card.instances):
for iii in range(i+1, i + 1 + card.intersect):
array[iii].addInstance()
instancesArr = list(map(lambda x: x.instances, array))
print(sum(instancesArr))
def parseLine(s: str):
idSplit = s.split(":")
id = getID(idSplit[0])
cardSplit = idSplit[1].split("|")
winning = re.findall(r'\d+', cardSplit[0])
card = re.findall(r'\d+', cardSplit[1])
cardInstance = T(id, winning, card)
return cardInstance
def getColor(s: str, color: str):
split = s.strip().split(" ")
if(color == split[1]):
return int(split[0])
return 0
def getID(split1):
digs = re.findall("\d+", split1)
id = digs[0]
return int(id)
if __name__ == "__main__":
main()
+87
View File
@@ -0,0 +1,87 @@
#!/usr/bin/env python3
# 2023 Day 5: If You Give A Seed A Fertilizer
def process_input(filename):
"""Acquire input data"""
with open(filename) as file:
input = file.read().splitlines()
seeds = []
maps = []
for line in input:
if line == '': continue
token = line.split()
if token[1] == 'map:':
maps.append([])
map_index = len(maps) - 1
continue
if token[0] == 'seeds:':
st = 1
while st < len(token):
seed_start = int(token[st])
seed_end = seed_start +int(token[st+1]) - 1
seeds.append((seed_start, seed_end))
st += 2
continue
dest = int(token[0])
source = int(token[1])
range_len = int(token[2])
source_end = source + range_len - 1
adjustment = dest - source
maps[map_index].append((source, source_end, adjustment))
return seeds, maps
def apply_maps():
lowest = 99999999999999999
for seed in seeds:
destinations = []
destinations.append(seed)
for map in maps:
sources = destinations
destinations = []
while len(sources) > 0:
source = sources.pop()
source_start, source_end = source
for range in map:
map_start, map_end, adjust = range
if source_start >= map_start and source_end <= map_end:
destinations.append((source_start+adjust, source_end+adjust))
break
if source_end < map_start or source_start > map_end:
continue
if source_start < map_start:
sources.append((source_start, map_start-1))
sources.append((map_start, source_end))
break
if source_end > map_end:
sources.append((source_start, map_end))
sources.append((map_end+1, source_end))
break
else:
destinations.append(source)
seed_lowest = lowest_location(destinations)
lowest = min(lowest, seed_lowest)
return lowest
def lowest_location(locations):
lowest = locations[0][0]
for location in locations:
lowest = min(location[0], lowest)
return lowest
#-----------------------------------------------------------------------------------------
filename = '5-input.txt'
#filename = 'sample.txt'
seeds, maps = process_input(filename)
lowest = apply_maps()
print()
print('Location:', lowest)
+31
View File
@@ -0,0 +1,31 @@
import re
import time
def main():
with open("/Users/samuelenocsson/dev/advent-of-code/5-input.txt", 'r') as file:
row_cache = {}
start_time = time.time()
seed_string = file.readline()
lines = file.readlines()
maps =[]
for idx, line in enumerate(lines):
numbers = [int(digit) for digit in re.findall(r'\d+', line)]
if len(numbers) > 0:
maps.append(numbers)
seeds = [int(digit) for digit in re.findall(r'\d+', seed_string)]
for seed in seeds:
sources = []
sources.append(seed)
for m in maps:
current = sources.pop()
current_start = current[0]
current_end = current[1]
location = -1
next = 0
if __name__ == "__main__":
main()
+250
View File
@@ -0,0 +1,250 @@
seeds: 1263068588 44436703 1116624626 2393304 2098781025 128251971 2946842531 102775703 2361566863 262106125 221434439 24088025 1368516778 69719147 3326254382 101094138 1576631370 357411492 3713929839 154258863
seed-to-soil map:
2056129205 3495540274 7275274
2093671499 2217398614 16037515
144190400 1167267743 4402289
685148999 560842720 46363553
148592689 1382926008 71816170
241575914 1243634776 139291232
1686196783 543577846 17264874
2601917866 2486088541 222990187
1703461657 1454742178 45658441
4200618033 2052611543 79792525
2063404479 2445531749 30267020
3026695548 4113017544 181949752
73663477 607206273 70526923
3412143232 2195535041 20126067
1381626519 809568775 38912495
4280410558 3277485604 9635485
1285511345 435930218 30230711
2009679577 4060471919 23976534
491535670 129136847 193613329
3016405776 2475798769 10289772
2035393617 2709078728 12153762
1760083914 1171670032 71964744
3988522413 2233436129 212095620
2824908053 4084448453 28569091
799335774 434222608 1707610
2109709014 3568263067 492208852
2047547379 3502815548 8581826
1275917650 466160929 9593695
731512552 475754624 67823222
380867146 698900251 110668524
1315742056 1500400619 65884463
801043384 848481270 151647344
3208645300 3292042342 203497932
952690728 0 129136847
1081827575 1000128614 167139129
0 1731434235 73663477
1749120098 423258792 10963816
2853477144 3511397374 56865693
1585688167 322750176 100508616
3432269299 2721232490 556253114
1420539014 1566285082 165149153
2973473810 2009679577 42931966
220408859 677733196 21167055
4290046043 3287121089 4921253
2033656111 2215661108 1737506
1248966704 1805097712 26950946
2910342837 2132404068 63130973
soil-to-fertilizer map:
3192416630 3819045895 47516706
39972266 597632895 4546595
2584201752 2580457211 100644566
2272135078 174545609 40291463
2819419661 2681101777 89335599
3239933336 3528823147 72816699
44518861 2232362178 145175982
2519969464 2377538160 64232288
1852478702 2770437376 313570784
2166049486 2441770448 106085592
4133995881 3866562601 160971415
1626150228 975660836 106177604
2908755260 422379995 175252900
3312750035 4178991584 115975712
1142288544 1324281099 483861684
833150172 1928293653 304068525
1732327832 1808142783 120150870
2684846318 39972266 134573343
3133663001 4027534016 58753629
189694843 602179490 373481346
3758375673 4086287645 92703939
3428725747 3199173221 329649926
1137218697 2547856040 5069847
4068485661 3133663001 65510220
590707513 1081838440 242442659
2312426541 214837072 207542923
563176189 2552925887 27531324
3851079612 3601639846 217406049
fertilizer-to-water map:
153835826 1814144363 127150990
1926426485 1614900585 14868868
2139872846 3136260217 42408895
3310771078 2202805875 59788141
83898078 1578023222 36877363
652411041 1574694502 3328720
2080480520 3785135933 59392326
3370559219 3272622808 82257970
3132498144 2037809941 164995934
2678755579 3455437189 65205729
3674754588 3844528259 234175097
2182281741 3520642918 59000325
570340096 1492623557 82070945
2779822218 2446205321 138940597
2037809941 2703025450 42670579
3515202222 2342244856 103960465
3998026660 4136896949 144793347
955105072 0 84792564
3452817189 3073875184 62385033
77176799 1459627033 6721279
4142820007 4078703356 58193593
280986816 1091602584 230166265
1701766245 1321768849 78671169
2987155826 2872940965 145342318
2418013523 3615504153 169631780
2587645303 2262594016 79650840
2667296143 3354880778 11459436
2743961308 3579643243 35860910
1880850385 1046026484 45576100
3297494078 4281690296 13277000
2918762815 2804547954 68393011
1854575140 1466348312 26275245
3908929685 3366340214 89096975
511153081 1400440018 59187015
655739761 864167436 181859048
120775441 1629769453 33060385
2241282066 2745696029 58851925
2300133991 2585145918 117879532
4201013600 3178669112 93953696
837598809 84792564 117506263
1039897636 202298827 661868609
3619162687 3018283283 55591901
0 1736967564 77176799
1780437414 1662829838 74137726
water-to-light map:
279076302 606101520 367597147
3291538704 3736283841 125013874
0 1709355698 279076302
2106348780 1988432000 822929157
2929277937 0 362260767
890514202 2811361157 924922684
3416552578 973698667 444745137
1815436886 1418443804 290911894
646673449 362260767 243840753
light-to-temperature map:
208346365 819874354 29069132
731840321 689055790 58614896
4186248520 4104876526 108718776
3429769554 3384048873 23936103
1459123931 2691296758 217855736
790455217 952719646 105546549
1416544830 2047230764 42579101
0 1202755810 208346365
1399364673 1598820754 17180157
2576491919 747670686 452381
901868462 2408707242 282589516
3626168682 4259315983 35651313
341191657 748123067 71751287
2721433915 1411102175 187718579
3822370242 3740998248 198425166
3245552556 4213595302 45720681
1676979667 100628240 254569707
896001766 2041364068 5866696
3291273237 3245552556 138496317
3661819995 3580448001 160550247
2063025564 380090092 308965698
4020795408 3939423414 165453112
237415497 848943486 103776160
1931549374 1909887878 131476190
2576944300 1058266195 144489615
717031505 2089809865 14808816
412942944 2104618681 304088561
1209350123 0 100628240
1309978363 1820501568 89386310
3453705657 3407984976 172463025
2371991262 1616000911 204500657
1184457978 355197947 24892145
temperature-to-humidity map:
4116612848 1770461885 178354448
475467700 3077125572 130863723
1272723717 1181397963 5578998
3758341401 495891106 279864899
1687813623 1591451985 2235236
2530388822 2518678506 215908033
2282034531 2032693852 208761140
1471990450 379604394 116286712
1817301926 3588566075 238614487
3086830522 2960704657 28309403
3692580145 2002277669 19886809
616860797 3221548716 360840790
3115139925 1226570112 16611162
336172750 170230298 133118381
977701587 1693223682 77238203
1366414227 775756005 105576223
2055916413 2734586539 226118118
4038206300 2287329439 78406548
3712466954 2241454992 45874447
3556277513 2516499157 2179349
1278302715 2989014060 88111512
1588277162 1593687221 99536461
2746296855 3827180562 340533667
469291131 3582389506 6176569
1054939790 1960273136 42004533
1247816059 3207989295 13559421
2490795671 1186976961 39593151
1261375480 1948816333 11348237
36107015 881332228 300065735
1096944323 2365735987 150763170
3131751087 303348679 76255715
3558456862 36107015 134123283
3208006802 1243181274 348270711
606331423 2022164478 10529374
1690048859 4167714229 127253067
1247707493 1960164570 108566
humidity-to-location map:
3760908805 3662107228 155796250
1580497895 3884288658 144897726
3166374808 442179790 213926492
121876139 656106282 138383174
393463083 2300882189 128101885
2948945727 3512929162 110263469
521564968 2652674020 210495874
1940349169 3864399213 19889445
1197505529 794489456 93759960
904168980 2539693608 75416982
1725395621 3623192631 38914597
2881030575 888249416 49678445
2116891732 1943237764 146499392
979585962 2615110590 37563430
3143485439 3262014106 22889369
791255257 4029186384 109003936
4209132419 4140663408 85834877
1764310218 192277746 165625801
2023373170 2466550792 73142816
4140663408 4226498285 68469011
2269931546 1003317103 611099029
1291265489 0 119152028
2930709020 3243777399 18236707
732060842 1884043349 59194415
1410417517 1614416132 170080378
1960238614 937927861 63134556
1929936019 2089737156 10413150
3380301300 2863169894 380607505
3916705055 3291443897 221485265
355896365 2428984074 37566718
2254686 3817903478 46495735
2096515986 2280506443 20375746
1017149392 2100150306 180356137
0 1001062417 2254686
260259313 1784496510 95637052
48750421 119152028 73125718
3059209196 357903547 84276243
2263391124 3284903475 6540422
900259193 1880133562 3909787
+33
View File
@@ -0,0 +1,33 @@
seeds: 79 14 55 13
seed-to-soil map:
50 98 2
52 50 48
soil-to-fertilizer map:
0 15 37
37 52 2
39 0 15
fertilizer-to-water map:
49 53 8
0 11 42
42 0 7
57 7 4
water-to-light map:
88 18 7
18 25 70
light-to-temperature map:
45 77 23
81 45 19
68 64 13
temperature-to-humidity map:
0 69 1
1 0 69
humidity-to-location map:
60 56 37
56 93 4
+96
View File
@@ -0,0 +1,96 @@
from concurrent.futures import ProcessPoolExecutor
import re
import time
def main():
with open("/Users/samuelenocsson/dev/advent-of-code/5-input.txt", 'r') as file:
row_cache = {}
start_time = time.time()
seed_string = file.readline()
lines = file.readlines()
for idx, line in enumerate(lines):
numbers = [int(digit) for digit in re.findall(r'\d+', line)]
row_cache[idx] = numbers
digits = [int(digit) for digit in re.findall(r'\d+', seed_string)]
seeds = []
location = -1
next = 0
with ProcessPoolExecutor() as executor:
for i, d in enumerate(digits):
if i != next: continue
first = digits[i]
first_range = digits[i+1]
print(f"{first} -> {first + first_range}")
results = []
get_location(first, first_range, row_cache)
next += 2
#seeds = getSeeds(seed_string)
#for seed in seeds:
#seed = get_location(lines, seed)
#locations.append(seed)
#location = min(f.result() for f in seeds)
location = min(seeds)
print(f"Closest location {location}")
end_time = time.time()
elapsed_time = end_time - start_time
print(f"Elapsed time: {elapsed_time} seconds")
def chunks(lst, chunk_size):
for i in range(0, len(lst), chunk_size):
yield lst[i:i + chunk_size]
def process(list, row_cache):
seeds = []
for s in list:
#seeds.append(executor.submit(get_location, s))
seeds.append(get_location(s, row_cache))
#return min(f.result() for f in seeds)
return min(seeds)
def get_location(from_seed, to_seed, row_cache):
nrLines = len(row_cache)
init_seed = seed
#print(f"finding location for {seed}")
new_seed = seed
fast_forward = False
for i in range(0, nrLines):
mappings = row_cache.get(i)
if len(mappings) > 0 and fast_forward: continue
if len(mappings) == 0:
fast_forward = False
continue
source = mappings[1]
destination = mappings[0]
r = mappings[2]
if source <= seed <= source + r:
diff = seed - source
new_seed = destination + diff
fast_forward = True
#print(f"{seed} -> {new_seed}")
seed = new_seed
#print(f"Location {init_seed} -> {seed}")
return seed
def getSeeds(s: str):
digits = [int(digit) for digit in re.findall(r'\d+', s)]
seeds = []
next = 0
for i, d in enumerate(digits):
if i != next: continue
first = digits[i]
first_range = digits[i+1]
for nr in range(first, first + first_range):
seeds.append(nr)
next += 2
return seeds
if __name__ == "__main__":
main()
+2
View File
@@ -0,0 +1,2 @@
Time: 44 89 96 91
Distance: 277 1136 1890 1768
+2
View File
@@ -0,0 +1,2 @@
Time: 7 15 30
Distance: 9 40 200
+25
View File
@@ -0,0 +1,25 @@
import re
def main():
with open("6-input.txt", 'r') as file:
winning_distances = []
lines = file.readlines()
time = ''.join(re.findall('\d+', lines[0]))
distance = ''.join(re.findall('\d+', lines[1]))
result = calcualte_distance(int(time), int(distance))
winning_distances.append(len(result))
winning_totals = 1
for value in winning_distances:
winning_totals *= value
print(winning_totals)
def calcualte_distance(time: int, distance: int):
reaches_longer = []
for i in range(0, time):
d = i * (time - i)
if d > distance:
reaches_longer.append(d)
return reaches_longer
if __name__ == "__main__":
main()
+1000
View File
File diff suppressed because it is too large Load Diff
View File
+14
View File
@@ -0,0 +1,14 @@
AAAAA 2
22222 3
AAAAK 5
22223 7
AAAKK 11
22233 13
AAAKQ 17
22234 19
AAKKQ 23
22334 29
AAKQJ 31
22345 37
AKQJT 41
23456 43
+94
View File
@@ -0,0 +1,94 @@
from functools import cmp_to_key
value = ["J","1", "2", "3", "4", "5", "6", "7", "8", "9", "T", "Q", "K", "A"]
class Hand:
def __init__(self, hand: str, bet: int, power: int, unsorted_power: int):
self.hand = hand
self.bet = bet
self.power = power
self.unsorted_power = unsorted_power
def bet(self):
return self.bet
def main():
with open("7-input.txt", 'r') as file:
hands = []
for line in file.readlines():
line = line.strip()
split = line.split(' ')
hands.append(Hand(split[0], int(split[1]), power(split[0]), unsorted_power(split[0])))
p = list(sorted(hands, key=cmp_to_key(custom_comparator), reverse=True))
mapped= list(map(lambda x: (x.hand, x.power, x.bet), p))
print(mapped)
result = 0
for i, hand in enumerate(p):
rank = (len(p)-i)
product = hand.bet * rank
result = result + product
print(result)
def custom_comparator(element1: Hand, element2:Hand):
# Replace this with your own logic to compare two elements
# Here, we are comparing based on the length of the strings
if element1.power < element2.power:
return -1
elif element1.power > element2.power:
return 1
else:
for i in range(0,5):
v1 = value.index(element1.hand[i])
v2 = value.index(element2.hand[i])
if v1 < v2:
return -1
elif v1 > v2:
return 1
return 0
def unsorted_power(hand: str):
unsorted_hand_power = 0
for i, char in enumerate(hand):
unsorted_hand_power += value.index(char) * (1000 - (pow(i, 2)))
return int(unsorted_hand_power)
def power(hand: str):
power = []
j_count = hand.count("J")
if j_count == 5: return 500
for char in hand:
if char == 'J': continue
count=hand.count(char)
t = (count, char, value.index(char))
if count > 0 and power.count(t) == 0:
power.append(t)
s = sorted(power, key=lambda x: (x[0],x[2]),reverse=True)
highest = s[0]
nd_highest = None
if len(s) > 1:
nd_highest = s[1]
count = highest[0]
if count == 5 or count + j_count == 5:
return 500 #+ value.index(first[1])
if count == 4 or count + j_count == 4:
return 400 #+ value.index(first[1])
if count == 3 or count + j_count == 3:
j_count = 0
if nd_highest != None:
second = nd_highest[0]
if second == 2 or second + j_count == 2:
return 300# + value.index(first[1]) + value.index(second[1])
return 200# + value.index(first[1])
if count == 2 or count + j_count == 2:
j_left = count - j_count
second = nd_highest[0]
if second == 2:
return 150# + value.index(first[1]) + value.index(second[1])
return 100# + value.index(first[1])
return 1
if __name__ == "__main__":
main()
+740
View File
@@ -0,0 +1,740 @@
LLRLLRRLRLRRRLRRLLRRRLRLRLRRLRRRLRRLRLRLLRLLLRRRLRRLRRRLRRRLRRRLRLRRLLRRLRRLRRLRRRLRLRRRLLRLRRLRRRLRLRRRLRRRLRLRRRLLRRRLRRRLRLRRLRLRRRLLRRLRRLRRLRRLRLRLRRRLLRRRLRRLRRRLRLRLRRRLLRLRRLLRLRRLRLRRRLRLRRLLRRRLLRRLRLRLLRLLRRLRRLLRRLRLRRLRLRLRRRLRRLRLLLLRRLRLRLRRRLLLRRRLRRLRRLRLLRLRRRLLLRRRLRRRLRRRR
NQT = (TXC, RVJ)
FPT = (PNS, KJL)
BNQ = (THG, LCV)
SPL = (VBH, NNV)
TLM = (LVQ, PGT)
GHC = (XKN, SPR)
PHT = (HMF, DST)
FSF = (JCM, SMT)
GDD = (FHJ, RBS)
GVR = (FVD, FVD)
SST = (PMF, MGC)
ZZZ = (VLV, SQV)
SDV = (DBL, GTL)
XSP = (GRV, RFM)
SKG = (NGH, VDX)
BPK = (RMK, LCQ)
VSC = (DRN, SFR)
BFR = (BJR, GMD)
HTM = (PFM, LVD)
XVP = (LDP, LDP)
DRD = (SCH, LKD)
DSJ = (GSQ, JTN)
VTS = (BNQ, VFX)
KVF = (HTP, MQK)
GPS = (FXQ, TPF)
VRC = (RTK, RTK)
HRD = (PMQ, JCR)
DJK = (FTC, KXH)
VGJ = (PCJ, TVH)
QMN = (TLC, HNG)
DMH = (QSD, PDP)
CRL = (VFR, MDR)
XGV = (CMV, FTV)
XJX = (HTM, HHG)
SQP = (XKK, KJF)
PXZ = (JCK, PTH)
BDV = (JMH, CND)
FBD = (CQS, QCN)
TRS = (FGM, NKF)
TLC = (HBC, FRC)
DKR = (LCP, VLD)
GTF = (QHD, PBB)
NCC = (HJF, LNR)
KGS = (KPF, GTB)
CPQ = (SLR, DRD)
RJQ = (KXK, BFR)
XSQ = (PNN, NMG)
DVP = (MBH, QLV)
CQL = (DVP, VHQ)
CPV = (MDL, VFB)
VHV = (CQS, QCN)
NRD = (KSC, HKX)
STX = (CGJ, PGK)
CNP = (FVB, MCN)
JXT = (DXT, LHK)
GHG = (MCL, MPB)
PGK = (RMS, SBC)
DNH = (FSV, RNS)
TFZ = (NQT, PBD)
MBQ = (DPH, FDK)
SJQ = (JLB, LJJ)
MBN = (FTD, CDB)
TDJ = (FJB, PQX)
DXT = (FJP, HGQ)
MSG = (MSM, CXN)
RTK = (GVR, GVR)
SDX = (VTS, MRG)
VCX = (QTL, NVV)
XCS = (KLR, THD)
RDD = (QDS, JST)
FVB = (BLD, NPF)
LVD = (JXC, FQR)
TMR = (SNJ, DML)
RCH = (JST, QDS)
RVJ = (XMN, SDT)
SQV = (MVP, MKC)
HDB = (LTL, JJP)
LVC = (CLL, CLL)
FGM = (TPG, PHK)
SCS = (MLK, TKF)
PRF = (TLB, KTT)
MPM = (NMN, KGS)
MGC = (NLT, MGS)
CNK = (BFR, KXK)
FXQ = (JMX, LLL)
GTB = (MFM, PMV)
VXS = (DPN, FPN)
NRB = (SCS, SGH)
QLJ = (NLL, VMM)
PNN = (SFJ, HSR)
BRJ = (RMQ, XLJ)
SNF = (FMH, MNR)
VLD = (SHN, FBG)
FSM = (GKF, DBC)
MHP = (LBX, KQH)
NSQ = (QKK, KND)
RRT = (RMK, LCQ)
BCX = (GTM, MVV)
XSX = (XFK, XNF)
TKF = (MFF, VCV)
HPD = (GHC, RKN)
MRG = (BNQ, VFX)
QTK = (QRT, RRB)
HFF = (NKD, SXP)
MFM = (BRB, DDN)
VVL = (GPC, BRJ)
CST = (GQT, NLG)
THD = (MVK, DRJ)
XFN = (JNC, MNF)
NKH = (PMD, BDV)
NLT = (HKK, KCD)
VXR = (XCS, GRX)
SDS = (JBV, JFM)
BFM = (XXG, CHQ)
PMD = (JMH, CND)
VVF = (GQT, NLG)
FGG = (NRD, SNP)
LKD = (NGK, SQP)
RSV = (TXL, GPD)
LNR = (RDB, NTD)
RPL = (SNB, MHK)
CCG = (JDT, PJD)
TKR = (TMD, VCL)
DRJ = (CQL, XFH)
JFM = (MMV, GPS)
FJP = (BDM, QXN)
QJS = (BFM, RHM)
KTT = (PXV, VJV)
XXB = (VKG, HXL)
RMK = (DBR, HFQ)
NGK = (KJF, XKK)
NPF = (SMK, BTJ)
RBS = (PGN, GNH)
PNS = (VTJ, KSM)
BCK = (SDX, NRF)
RNS = (XVS, KFX)
PDB = (BHH, BHH)
GMQ = (MRD, JRG)
DGM = (HDV, GSD)
TLB = (PXV, VJV)
QRT = (FRS, FFT)
VSX = (NLL, VMM)
GSQ = (JRJ, LGV)
TXC = (XMN, SDT)
HGQ = (QXN, BDM)
PMQ = (KBB, NRH)
KRC = (DGM, XCR)
QLZ = (TKM, HTF)
NJM = (GPC, BRJ)
FRG = (QLS, GXP)
NMG = (SFJ, HSR)
JDT = (TDF, QHT)
LFC = (RFM, GRV)
TXL = (XSX, FTP)
DKG = (JNL, XBR)
VKF = (GTM, MVV)
VQV = (RHT, SDS)
SJH = (LPV, TRQ)
KSM = (LHX, CPQ)
QMH = (MMD, GPB)
VNP = (TRQ, LPV)
NBM = (JPF, KRM)
RGQ = (TMH, KQR)
RSM = (SMP, KSG)
HDV = (VXS, VQG)
TTD = (CDB, FTD)
GXF = (SLN, SCF)
QHT = (TMR, QTH)
MNR = (VXR, GDS)
GSA = (THS, NKH)
XKN = (GNB, VLQ)
HHQ = (RRB, QRT)
CLC = (THS, NKH)
BSN = (QKN, QKN)
QRB = (KDT, JSL)
JCX = (VCX, DXP)
BDM = (SQN, TBH)
GQT = (DNB, NTS)
QSF = (KXH, FTC)
HFQ = (NNQ, LLM)
VFB = (NGF, NXB)
JMX = (HFB, DNR)
VKS = (NBM, NQF)
PGN = (FBD, VHV)
PNQ = (KQR, TMH)
QLM = (VVL, NJM)
PRB = (KQD, QRB)
GTL = (VQJ, DJR)
KNL = (JRN, KVF)
VMT = (LTL, JJP)
QKN = (PHM, VQS)
QBL = (LXK, PRF)
PCT = (VNP, SJH)
QLV = (HXF, DXH)
HNN = (DSJ, XDN)
LGV = (VVD, XXB)
XCB = (XXQ, CHX)
GXC = (FGG, MSX)
SLN = (VLP, SST)
NQQ = (SXP, NKD)
DRN = (DPC, TCV)
JHF = (QTK, HHQ)
GPM = (GTF, NCX)
PFM = (JXC, JXC)
KBT = (KQH, LBX)
XFH = (VHQ, DVP)
CPT = (VSD, TKR)
GSX = (CTF, XXX)
SPR = (GNB, VLQ)
XBP = (MXH, TBJ)
VKG = (PKS, CPT)
THG = (FRP, FRP)
SHN = (FRG, TCF)
BFS = (RPL, JRV)
PHK = (BQG, BMH)
SMK = (VRV, FDG)
PBF = (MSG, XGT)
NKF = (TPG, PHK)
VDQ = (MHP, KBT)
JRG = (DXJ, JCX)
MHK = (QTS, CRL)
CXN = (FBR, FCT)
DHT = (XXQ, CHX)
DML = (SPL, TBX)
BTJ = (FDG, VRV)
KVG = (TJJ, TRS)
JPH = (CLC, DXZ)
HXL = (PKS, CPT)
RDB = (PKM, FLG)
CTF = (NLX, SJQ)
BMH = (GVP, NSQ)
GTP = (NMG, PNN)
KJL = (KSM, VTJ)
SLR = (LKD, SCH)
TJJ = (NKF, FGM)
DPH = (HHT, NRB)
PBN = (CLC, CLC)
FFT = (DJK, QSF)
RTL = (TBJ, MXH)
PJD = (TDF, QHT)
HTP = (BGK, NCC)
MDL = (NXB, NGF)
CGJ = (SBC, RMS)
RTR = (LHK, DXT)
MLR = (JNC, MNF)
DXL = (RKN, GHC)
QTS = (VFR, MDR)
LLM = (KSK, BHN)
FFJ = (HGD, HGD)
PQX = (VRC, KXG)
XFK = (QNM, TMC)
FVD = (HTF, TKM)
CSR = (XDN, DSJ)
VPN = (DPH, FDK)
TJN = (HGC, HJH)
KSC = (SVX, SVX)
TLH = (FSV, RNS)
QTH = (DML, SNJ)
VQJ = (SMR, KCL)
GNP = (JRQ, GBR)
TKB = (TLC, HNG)
FBV = (BFM, RHM)
DMS = (BTG, NXV)
VDX = (BCM, RNG)
MSN = (QTK, HHQ)
TKM = (LSM, PBF)
FSS = (MCN, FVB)
DLA = (PHM, VQS)
LXK = (KTT, TLB)
JBV = (MMV, GPS)
FFQ = (QJS, FBV)
MXH = (RPP, LKF)
RKN = (SPR, XKN)
FDG = (RSC, QMH)
NLL = (VKS, FPF)
XDN = (JTN, GSQ)
FLS = (JNL, XBR)
MLA = (PTH, JCK)
GTM = (FSS, CNP)
NVV = (LLR, NLV)
TBX = (VBH, NNV)
HTG = (VDQ, GFH)
VLQ = (HXR, QNQ)
JSL = (MVC, DJM)
BPX = (VVL, NJM)
FBG = (FRG, TCF)
PFS = (HMH, KFF)
GPB = (DDH, RSM)
JFB = (FXX, GXC)
XJZ = (VQS, PHM)
FRS = (QSF, DJK)
NKP = (PDB, SGT)
KSB = (CTF, XXX)
DTL = (FMH, MNR)
HSN = (PBN, JPH)
JCQ = (XCB, DHT)
GBR = (NKP, GHV)
BKL = (CKM, XJX)
JLH = (XGV, MXR)
TBJ = (LKF, RPP)
RSJ = (HVN, KKH)
SVX = (BSN, BSN)
GRV = (CHT, NMV)
TKX = (RHT, SDS)
MQK = (BGK, NCC)
KLR = (DRJ, MVK)
NCH = (BCX, VKF)
NLX = (JLB, LJJ)
VHQ = (MBH, QLV)
QXR = (NCH, FRT)
FQS = (VGJ, HFG)
LCP = (SHN, FBG)
NCX = (QHD, PBB)
SXK = (HGD, ZZZ)
RNR = (RTR, JXT)
VQG = (FPN, DPN)
RMJ = (HNN, CSR)
KSL = (BCK, QQJ)
HCK = (QMN, TKB)
LBX = (HFD, XQH)
MTL = (NCH, FRT)
XHR = (KFL, TLM)
LLH = (LFC, XSP)
JRJ = (XXB, VVD)
KGM = (FQS, KGC)
SDT = (MNQ, GTN)
GJQ = (KLG, DMS)
RNG = (RNR, GHB)
DCK = (TXL, GPD)
DXJ = (DXP, VCX)
SNP = (KSC, HKX)
KRS = (BMQ, GBP)
GPC = (RMQ, XLJ)
CDB = (MXQ, XLM)
NLV = (FGS, KNL)
GNB = (HXR, QNQ)
KFL = (PGT, LVQ)
HQL = (QXR, MTL)
BJR = (PBH, PHT)
QTL = (LLR, NLV)
SNB = (CRL, QTS)
LDP = (PBN, PBN)
DFJ = (FHJ, RBS)
JJP = (XMJ, VVQ)
GQC = (QRB, KQD)
SFR = (DPC, TCV)
MPB = (FSM, GGL)
SXP = (QFP, GFQ)
MNF = (DKG, FLS)
KLG = (NXV, BTG)
TVH = (JFB, PJJ)
SHJ = (SFX, TMT)
RHF = (SRD, KBV)
XBR = (NQQ, HFF)
PBD = (RVJ, TXC)
XXQ = (KSL, DDL)
FTP = (XNF, XFK)
HBC = (JTF, LLH)
BTG = (HDB, VMT)
KFX = (DMH, GBM)
SGH = (MLK, TKF)
CVS = (GBP, BMQ)
DDL = (BCK, QQJ)
PKM = (QNV, DPJ)
QSR = (KJL, PNS)
KPD = (PCT, MCP)
BHH = (LVC, LVC)
MDR = (HTG, SFD)
HKK = (DXL, HPD)
SMD = (RCQ, NJD)
XMJ = (MKM, NTN)
CQS = (DNH, TLH)
PBH = (HMF, DST)
MKC = (CJH, JDQ)
KLL = (FJB, PQX)
CXP = (VGS, HFX)
JPF = (STX, BXV)
CRV = (RCQ, NJD)
FDK = (NRB, HHT)
BTT = (CRV, SMD)
RHT = (JBV, JFM)
MXR = (FTV, CMV)
DBL = (DJR, VQJ)
CHX = (DDL, KSL)
JKX = (VDX, NGH)
MQA = (HTF, TKM)
DJQ = (DLT, SBS)
VFR = (SFD, HTG)
NMN = (KPF, GTB)
JNK = (VNQ, TPT)
KJH = (GTF, NCX)
QLS = (GXF, SCK)
NHR = (PNQ, RGQ)
FPF = (NBM, NQF)
BKP = (KLL, TDJ)
SBC = (TTF, SSS)
XMN = (GTN, MNQ)
PBB = (RRT, BPK)
XVS = (GBM, DMH)
HFX = (MPN, JLH)
KDS = (TXG, DBT)
DDN = (GDD, DFJ)
SSS = (CST, VVF)
NGH = (RNG, BCM)
HNG = (HBC, FRC)
CND = (RCH, RDD)
HFD = (NHR, RDV)
FRC = (JTF, LLH)
TBH = (KDS, CNQ)
QNQ = (TFB, KGM)
SMT = (MBK, TJN)
NGF = (BPV, JNR)
XLM = (XVP, QCK)
JLB = (SNF, DTL)
NXV = (HDB, VMT)
VSD = (TMD, VCL)
TMT = (GHG, PVG)
NNV = (JKX, SKG)
HFB = (QQK, BKP)
BLD = (SMK, BTJ)
JGH = (TKB, QMN)
XXX = (NLX, SJQ)
LQH = (VLD, LCP)
KRM = (BXV, STX)
HVN = (FTH, QBL)
QXM = (KLG, DMS)
DBR = (LLM, NNQ)
MVP = (CJH, JDQ)
FBR = (MBQ, VPN)
SFP = (HRD, SGC)
HGD = (SQV, VLV)
CJH = (JNK, DXR)
DJM = (XSQ, GTP)
KXG = (RTK, RKV)
HTF = (LSM, PBF)
FXX = (MSX, FGG)
MFF = (VSC, QCP)
TMH = (HQL, GSJ)
KBB = (CHN, FSF)
XTV = (SBH, SGR)
MFH = (JGH, HCK)
SGC = (JCR, PMQ)
TRQ = (LVM, FFQ)
VCL = (DXK, RBD)
QSD = (VQF, JCQ)
FQR = (FFJ, SXK)
KQD = (KDT, JSL)
XLJ = (DCG, MPM)
FXL = (TFF, SSP)
RRN = (DBL, GTL)
CKM = (HTM, HHG)
VLP = (MGC, PMF)
KPQ = (MDL, VFB)
XQH = (RDV, NHR)
JRN = (MQK, HTP)
JMH = (RCH, RDD)
JRV = (SNB, MHK)
QCP = (DRN, SFR)
LLR = (KNL, FGS)
NMV = (DLJ, DJQ)
KBV = (GQC, PRB)
JXC = (FFJ, FFJ)
LFS = (MHB, VXT)
DST = (XHR, PCS)
SNJ = (TBX, SPL)
KND = (FDH, CCG)
CMT = (KPK, RMJ)
HHG = (PFM, LVD)
RPP = (MBN, TTD)
MBK = (HJH, HGC)
NQF = (JPF, KRM)
FPN = (BFS, RVB)
GFQ = (RTL, XBP)
SCH = (NGK, SQP)
VFX = (THG, LCV)
CTG = (TMT, SFX)
PGT = (CMT, RFB)
RLB = (TFF, SSP)
STD = (SJT, TFZ)
VMM = (FPF, VKS)
SFX = (GHG, PVG)
BXV = (CGJ, PGK)
FBT = (TBM, RHF)
LJJ = (SNF, DTL)
LKF = (MBN, TTD)
QNV = (KRC, VMF)
VGS = (MPN, JLH)
MKM = (JJD, BKL)
HKX = (SVX, RKF)
MSL = (CRV, SMD)
RHM = (CHQ, XXG)
FRP = (MSF, MSF)
VCV = (VSC, QCP)
FMH = (VXR, GDS)
FLR = (VGS, HFX)
GHV = (PDB, SGT)
FHQ = (MRD, JRG)
HJF = (RDB, NTD)
MSM = (FBR, FCT)
GHB = (JXT, RTR)
BMQ = (MFH, GTR)
MCP = (VNP, SJH)
SRD = (PRB, GQC)
DXR = (TPT, VNQ)
RFB = (KPK, RMJ)
GSJ = (MTL, QXR)
FHJ = (PGN, GNH)
LCQ = (DBR, HFQ)
GBM = (PDP, QSD)
TPT = (JHF, MSN)
MVV = (CNP, FSS)
KXD = (LQH, DKR)
PXV = (QXM, GJQ)
BHN = (KPQ, CPV)
SBS = (RRN, SDV)
LHX = (SLR, DRD)
TBM = (KBV, SRD)
DXK = (PLP, FGX)
NKD = (QFP, GFQ)
PVG = (MCL, MPB)
TTF = (VVF, CST)
PDP = (VQF, JCQ)
MSX = (NRD, SNP)
CMV = (RSV, DCK)
PMF = (NLT, MGS)
MSF = (SJT, SJT)
NTC = (DKR, LQH)
GNH = (VHV, FBD)
GSD = (VQG, VXS)
VBH = (JKX, SKG)
GTR = (JGH, HCK)
SSL = (MHB, VXT)
NLG = (NTS, DNB)
JRQ = (NKP, GHV)
MLK = (MFF, VCV)
BLF = (HRD, SGC)
BGK = (HJF, LNR)
VQF = (XCB, DHT)
GVP = (QKK, KND)
FTD = (MXQ, XLM)
JST = (JFC, KVG)
JFC = (TJJ, TRS)
MMD = (DDH, RSM)
SBH = (TKX, VQV)
PDH = (CVS, KRS)
NRH = (CHN, FSF)
MRD = (JCX, DXJ)
KGC = (VGJ, HFG)
RRB = (FFT, FRS)
KQR = (GSJ, HQL)
FSV = (XVS, KFX)
DBC = (PSR, QXX)
GMR = (KKH, HVN)
CLG = (CLL, PXZ)
JNL = (HFF, NQQ)
JCR = (KBB, NRH)
FTV = (DCK, RSV)
DPC = (FHQ, GMQ)
MVC = (XSQ, GTP)
KXK = (GMD, BJR)
DPJ = (KRC, VMF)
FTC = (GSX, KSB)
TBK = (QKN, XJZ)
VFG = (SHJ, CTG)
VXT = (QLJ, VSX)
MHB = (VSX, QLJ)
MMV = (TPF, FXQ)
QCN = (DNH, TLH)
KPK = (CSR, HNN)
RDV = (PNQ, RGQ)
DCG = (KGS, NMN)
FJB = (VRC, KXG)
NTD = (PKM, FLG)
DBT = (GPM, KJH)
LLL = (HFB, DNR)
SMR = (BPX, QLM)
MGS = (HKK, KCD)
HHT = (SCS, SGH)
MVK = (CQL, XFH)
GFH = (KBT, MHP)
JNC = (FLS, DKG)
QHD = (RRT, BPK)
NTN = (BKL, JJD)
VQS = (CNK, RJQ)
KQH = (XQH, HFD)
GGL = (DBC, GKF)
QQK = (KLL, TDJ)
LHK = (HGQ, FJP)
RKV = (GVR, PLT)
VKV = (TBM, RHF)
MPN = (XGV, MXR)
PHM = (RJQ, CNK)
TPG = (BQG, BMH)
CLL = (PTH, JCK)
MXQ = (XVP, QCK)
NXB = (BPV, JNR)
GTN = (PFS, HGV)
FRT = (VKF, BCX)
GRX = (THD, KLR)
VLV = (MVP, MKC)
NJD = (QBX, XTV)
VJV = (QXM, GJQ)
KPF = (MFM, PMV)
JCM = (TJN, MBK)
HFG = (TVH, PCJ)
HJH = (QNB, PDH)
JTN = (JRJ, LGV)
CHQ = (XFN, MLR)
JNR = (TXN, KPD)
BCM = (RNR, GHB)
PCS = (TLM, KFL)
DXP = (QTL, NVV)
KJF = (NTC, KXD)
DLT = (RRN, SDV)
QXN = (TBH, SQN)
TMC = (FBT, VKV)
PJJ = (GXC, FXX)
KXH = (KSB, GSX)
GDS = (XCS, GRX)
BQG = (GVP, NSQ)
XNF = (TMC, QNM)
RFM = (CHT, NMV)
JDQ = (JNK, DXR)
LKP = (MSF, STD)
TFB = (FQS, KGC)
DNR = (BKP, QQK)
FGX = (FPT, QSR)
HXR = (KGM, TFB)
XKK = (NTC, KXD)
FDH = (JDT, PJD)
FTH = (PRF, LXK)
TCF = (GXP, QLS)
TXN = (PCT, MCP)
TPF = (LLL, JMX)
LPV = (LVM, FFQ)
HXF = (FXL, RLB)
HGV = (KFF, HMH)
MCN = (BLD, NPF)
SMP = (BTT, MSL)
LVM = (FBV, QJS)
TCV = (GMQ, FHQ)
FLG = (DPJ, QNV)
PTH = (LFS, SSL)
SQS = (SHJ, CTG)
GBP = (MFH, GTR)
QCK = (LDP, HSN)
JCK = (LFS, SSL)
TNL = (LVC, CLG)
GKF = (QXX, PSR)
PCJ = (PJJ, JFB)
MBH = (DXH, HXF)
PLP = (FPT, QSR)
VXQ = (JRQ, GBR)
DDH = (KSG, SMP)
PKS = (TKR, VSD)
JRT = (CXP, FLR)
HMH = (SQS, VFG)
DNB = (JRT, BRM)
BRB = (DFJ, GDD)
PSR = (SFP, BLF)
KSK = (KPQ, CPV)
QXX = (BLF, SFP)
SSP = (GMR, RSJ)
VMF = (DGM, XCR)
MNQ = (PFS, HGV)
HSR = (VXQ, GNP)
KSG = (MSL, BTT)
VRV = (RSC, QMH)
XXG = (MLR, XFN)
RVB = (JRV, RPL)
KDT = (MVC, DJM)
SQN = (CNQ, KDS)
BPV = (TXN, KPD)
SJT = (PBD, NQT)
LCV = (FRP, LKP)
CNQ = (TXG, DBT)
GPD = (FTP, XSX)
CHN = (SMT, JCM)
XGT = (MSM, CXN)
TFF = (GMR, RSJ)
QKK = (FDH, CCG)
CHT = (DLJ, DJQ)
BRM = (CXP, FLR)
KFF = (VFG, SQS)
FGS = (KVF, JRN)
SFD = (GFH, VDQ)
RMQ = (MPM, DCG)
AAA = (SQV, VLV)
JJD = (XJX, CKM)
VVD = (HXL, VKG)
SCF = (VLP, SST)
RKF = (BSN, TBK)
LVQ = (CMT, RFB)
SCK = (SCF, SLN)
TXG = (GPM, KJH)
DXZ = (NKH, THS)
HMF = (PCS, XHR)
KKH = (QBL, FTH)
THS = (PMD, BDV)
FCT = (MBQ, VPN)
VVQ = (MKM, NTN)
QNM = (VKV, FBT)
LTL = (XMJ, VVQ)
TDF = (QTH, TMR)
VNQ = (JHF, MSN)
KCL = (QLM, BPX)
RMS = (TTF, SSS)
HGC = (QNB, PDH)
JTF = (LFC, XSP)
PMV = (DDN, BRB)
VTJ = (CPQ, LHX)
NNQ = (BHN, KSK)
NRF = (VTS, MRG)
QNB = (KRS, CVS)
RCQ = (QBX, XTV)
MCL = (FSM, GGL)
NTS = (JRT, BRM)
QQJ = (NRF, SDX)
QFP = (XBP, RTL)
DPN = (BFS, RVB)
XCR = (HDV, GSD)
SGT = (BHH, TNL)
JGA = (PBD, NQT)
LSM = (XGT, MSG)
PLT = (FVD, QLZ)
RSC = (MMD, GPB)
DXH = (RLB, FXL)
TMD = (DXK, RBD)
QDS = (JFC, KVG)
KCD = (DXL, HPD)
GMD = (PHT, PBH)
DLJ = (DLT, SBS)
DJR = (SMR, KCL)
SGR = (VQV, TKX)
RBD = (FGX, PLP)
SFJ = (GNP, VXQ)
GXP = (SCK, GXF)
QBX = (SBH, SGR)
+10
View File
@@ -0,0 +1,10 @@
LR
FFA = (FFB, XXX)
FFB = (XXX, FFZ)
FFZ = (FFB, XXX)
DDA = (DDB, XXX)
DDB = (DDC, DDC)
DDC = (DDZ, DDZ)
DDZ = (DDB, DDB)
XXX = (XXX, XXX)
+52
View File
@@ -0,0 +1,52 @@
import re
import math
def main():
with open("8-input.txt", 'r') as file:
maps = {}
starting_nodes = []
lines = file.readlines()
directions = re.findall("[a-zA-Z]", lines[0])
for i, line in enumerate(lines[2:]):
parsed = re.findall("[a-zA-Z]+", line)
if len(parsed) == 0: continue
if parsed[0].endswith('A'): starting_nodes.append(parsed[0])
maps[parsed[0]] = (parsed[1], parsed[2])
steps = []
for starter in starting_nodes:
steps.append(traverse_map(maps, directions, maps[starter], 0))
print(steps)
print(find_lcm_of_array(steps))
def find_lcm_of_array(arr):
# Ensure the array is not empty
if not arr:
return None
# Initialize lcm with the first element of the array
lcm_result = arr[0]
# Iterate through the array and find the LCM
for i in range(1, len(arr)):
lcm_result = math.lcm(lcm_result, arr[i])
return lcm_result
def traverse_map(maps, directions, nd, steps):
while(True):
step = steps % len(directions)
dir = directions[step]
if dir == "R":
next = nd[1]
if dir == "L":
next = nd[0]
steps += 1
if next.endswith('Z'):
return steps
nd = maps[next]
if __name__ == "__main__":
main()
+200
View File
@@ -0,0 +1,200 @@
26 35 42 63 136 327 729 1457 2648 4480 7229 11394 17952 28881 48234 84291 153739 289701 557511 1087187 2143197
-6 -7 -7 -6 -4 -1 3 8 14 21 29 38 48 59 71 84 98 113 129 146 164
10 21 39 71 124 205 321 479 686 949 1275 1671 2144 2701 3349 4095 4946 5909 6991 8199 9540
17 36 64 110 196 368 721 1447 2915 5792 11214 21016 38030 66460 112343 184105 293221 454988 689420 1022274 1486216
14 33 64 116 204 363 671 1289 2540 5066 10129 20190 40081 79524 158734 320937 659964 1379861 2920964 6221222 13247612
10 17 41 95 198 375 657 1081 1690 2533 3665 5147 7046 9435 12393 16005 20362 25561 31705 38903 47270
14 29 64 124 216 352 565 958 1808 3743 8000 16767 33646 64419 118683 213748 383770 699853 1311392 2526026 4956236
19 30 47 86 178 369 720 1307 2221 3568 5469 8060 11492 15931 21558 28569 37175 47602 60091 74898 92294
1 13 30 66 156 361 782 1589 3082 5828 10975 20973 41216 83707 175021 373168 802624 1726245 3691904 7830015 16453595
7 6 12 33 86 197 399 741 1345 2591 5587 13218 32302 77760 180292 399922 849043 1730420 3398238 6454079 11895222
20 40 66 104 168 288 538 1089 2290 4780 9636 18566 34162 60236 102272 168039 268424 418560 639342 959444 1417972
4 1 8 49 171 457 1047 2169 4174 7572 13095 21883 36015 59804 102558 183893 343184 655371 1256114 2380229 4418451
11 21 44 94 190 354 607 963 1421 1955 2502 2948 3112 2728 1425 -1295 -6081 -13759 -25360 -42150 -65662
-5 2 24 67 140 257 432 667 941 1223 1565 2410 5431 15611 46111 129246 340658 851773 2042419 4740096 10722177
30 42 54 78 144 309 666 1353 2562 4548 7638 12240 18852 28071 40602 57267 79014 106926 142230 186306 240696
4 5 6 4 -2 -6 16 144 614 2030 5756 14577 33738 72479 146164 279025 507368 882763 1474194 2367290 3657486
15 39 71 119 214 419 847 1704 3385 6680 13205 26287 52768 106695 216910 442638 905099 1850193 3769279 7624639 15257058
3 12 37 84 157 259 396 590 917 1601 3217 7084 15961 35198 74558 151062 293511 549970 1000717 1781348 3124429
30 52 78 111 156 226 363 678 1414 3032 6311 12445 23129 40681 68393 111605 180538 296816 506992 908439 1695878
13 11 22 61 142 275 477 809 1456 2892 6241 14089 32266 73589 165430 364651 786707 1661933 3443480 7011621 14053570
12 39 91 193 395 786 1514 2811 5024 8670 14583 24331 41297 73223 137768 274043 565775 1186884 2489910 5175384 10611406
17 30 44 61 96 187 413 924 1999 4173 8512 17166 34394 68332 133865 257067 481789 879104 1560460 2695547 4536052
4 11 19 37 82 184 404 887 1995 4606 10740 24810 56050 123161 263200 548769 1121742 2260137 4510825 8950315 17687738
7 27 59 103 159 227 307 399 503 619 747 887 1039 1203 1379 1567 1767 1979 2203 2439 2687
24 33 35 39 72 183 445 955 1832 3213 5247 8087 11880 16755 22809 30091 38584 48185 58683 69735 80840
14 25 44 81 158 317 646 1349 2901 6354 13911 29992 63242 130402 263910 526903 1042536 2050026 4008556 7783136 14964330
14 36 82 176 361 717 1400 2716 5251 10085 19128 35643 65091 116595 205685 359815 630008 1116030 2020826 3766194 7231721
7 22 46 81 131 199 287 419 728 1675 4501 12052 30162 69830 150484 304688 584717 1071500 1886512 3207283 5287285
0 13 51 141 338 752 1597 3285 6611 13106 25672 49656 94583 176907 324514 584721 1040090 1842598 3291085 6008902 11347440
26 54 99 165 256 376 529 719 950 1226 1551 1929 2364 2860 3421 4051 4754 5534 6395 7341 8376
5 8 30 96 252 576 1189 2266 4047 6848 11072 17220 25902 37848 53919 75118 102601 137688 181874 236840 304464
18 30 38 43 47 60 122 355 1072 2987 7605 17945 39891 84713 173697 346423 675094 1288516 2410936 4423047 7955159
15 33 70 148 318 690 1491 3159 6476 12736 23937 42981 73861 121799 193252 295586 435973 618611 838592 1069506 1239992
12 25 44 83 177 411 974 2247 4940 10314 20568 39558 74189 137162 252394 465548 863972 1613295 3022404 5655077 10515841
17 23 28 32 35 37 38 38 37 35 32 28 23 17 10 2 -7 -17 -28 -40 -53
20 27 34 41 48 55 62 69 76 83 90 97 104 111 118 125 132 139 146 153 160
14 28 63 140 289 549 968 1603 2520 3794 5509 7758 10643 14275 18774 24269 30898 38808 48155 59104 71829
11 13 25 60 131 258 496 1006 2196 4970 11163 24360 51603 107183 221143 457846 954845 2000571 4182761 8660420 17643527
1 12 46 110 209 345 517 731 1033 1584 2809 5682 12277 26869 58216 124413 263297 554524 1165328 2442470 5090777
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
10 19 28 36 37 21 -18 -55 28 563 2326 6990 18036 42542 94505 200604 409561 806558 1534779 2827723 5059814
8 31 67 121 207 352 604 1053 1886 3529 6995 14671 31953 70390 153340 325587 668932 1326467 2539083 4698765 8424403
15 39 77 136 230 387 668 1209 2294 4459 8612 16133 28911 49357 80812 129945 215765 396795 842423 2002558 4981136
8 4 -7 -26 -38 11 245 898 2373 5351 11022 21596 41452 79760 156506 316211 658402 1402950 3024695 6519782 13912298
24 49 97 177 299 483 776 1277 2170 3765 6547 11233 18837 30743 48786 75341 113420 166777 240021 338737 469615
-5 -4 3 23 81 241 651 1635 3864 8647 18392 37296 72332 134610 241198 417498 700281 1141494 1812961 2812109 4268859
13 24 37 60 120 280 664 1498 3179 6388 12267 22684 40614 70668 119806 198274 320809 508160 788977 1202124 1799476
-8 1 27 85 201 414 780 1377 2310 3715 5761 8649 12607 17880 24714 33333 43908 56517 71095 87373 104805
4 10 26 58 117 232 475 1002 2120 4392 8797 16987 31757 58013 104866 190153 350020 658890 1270556 2501848 5000829
5 23 60 133 271 521 957 1692 2895 4833 8000 13465 23669 44023 85797 170932 339537 660931 1249132 2283653 4036307
-6 0 21 76 210 510 1137 2387 4793 9279 17376 31509 55363 94335 156078 251142 393716 602474 901527 1321482 1900608
7 26 69 161 350 715 1369 2453 4123 6547 9953 14802 22202 34730 57889 102496 188375 349816 643357 1158551 2032494
8 24 59 124 241 451 822 1457 2502 4154 6669 10370 15655 23005 32992 46287 63668 86028 114383 149880 193805
14 25 29 28 36 87 252 670 1597 3476 7030 13379 24181 41796 69471 111543 173656 262987 388475 561046 793826
13 30 69 137 253 466 879 1679 3173 5830 10329 17613 28949 45994 70867 106227 155357 222254 311725 429489 582285
19 26 27 20 5 -1 63 341 1111 2848 6299 12570 23225 40397 66911 106419 163547 244054 355003 504944 704109
11 27 63 139 287 567 1091 2060 3840 7143 13442 25839 50726 100735 199668 390336 746521 1390611 2518849 4436587 7606449
8 16 24 32 40 48 56 64 72 80 88 96 104 112 120 128 136 144 152 160 168
24 40 58 74 78 56 3 -38 120 1023 4036 12295 32615 79211 180836 394437 831547 1710256 3459759 6934492 13857367
21 45 80 133 233 459 998 2243 4936 10358 20569 38708 69378 119166 197385 317176 497175 764035 1156198 1729439 2564855
-6 4 24 55 102 175 297 527 1012 2103 4618 10422 23632 52956 115951 246348 506054 1004014 1924812 3570721 6421890
5 14 25 41 81 201 538 1392 3361 7544 15827 31267 58589 104811 180012 298258 478701 746866 1136141 1689485 2461369
8 15 20 23 24 23 20 15 8 -1 -12 -25 -40 -57 -76 -97 -120 -145 -172 -201 -232
13 20 30 48 76 118 195 384 904 2280 5634 13208 29381 62826 131291 272156 564999 1177756 2456894 5095984 10438354
27 53 96 159 255 426 783 1588 3411 7409 15783 32472 64154 121681 222249 393008 677615 1148649 1931134 3246025 5487861
27 51 87 147 252 443 811 1568 3204 6815 14760 31931 68124 142316 290137 576563 1116981 2111495 3899953 7049103 12489112
15 38 65 106 199 432 972 2103 4287 8284 15397 27949 50166 89761 160728 288225 517106 927093 1660904 2979519 5376696
0 6 31 85 194 412 837 1643 3145 5918 10995 20188 36667 66241 120629 226030 444760 927057 2029015 4569804 10373398
19 26 33 40 47 54 61 68 75 82 89 96 103 110 117 124 131 138 145 152 159
10 25 53 115 238 467 889 1678 3189 6155 12074 23913 47303 92453 177072 330656 600572 1060453 1821507 3047439 4973788
-5 6 42 116 241 430 696 1052 1511 2086 2790 3636 4637 5806 7156 8700 10451 12422 14626 17076 19785
13 40 92 178 320 570 1025 1832 3175 5243 8195 12175 17526 25612 41304 79628 181985 452774 1136694 2772588 6484284
19 23 26 28 29 29 28 26 23 19 14 8 1 -7 -16 -26 -37 -49 -62 -76 -91
17 28 51 84 122 162 210 294 504 1118 2937 8043 21309 53122 123918 271257 560267 1098336 2054903 3687062 6371412
20 28 35 44 76 178 438 1031 2334 5162 11191 23648 48362 95284 180598 329559 580208 988128 1632419 2623084 4110032
5 20 47 86 137 200 275 362 461 572 695 830 977 1136 1307 1490 1685 1892 2111 2342 2585
26 38 56 87 148 291 641 1446 3149 6514 12872 24600 46007 84877 155011 280219 500340 880014 1521096 2579789 4289782
10 18 29 45 77 160 369 829 1716 3258 5769 9790 16486 28609 52706 104067 217586 470910 1031969 2252631 4845759
-1 10 31 62 103 154 215 286 367 458 559 670 791 922 1063 1214 1375 1546 1727 1918 2119
8 12 20 49 121 260 489 827 1286 1868 2562 3341 4159 4948 5615 6039 6068 5516 4160 1737 -2059
0 -4 -4 15 71 192 450 1034 2366 5263 11181 22696 44675 87230 172812 352167 738124 1573554 3362222 7111453 14767575
19 37 73 130 204 280 340 404 636 1566 4512 12341 30798 70777 152136 310006 605061 1139971 2085359 3720200 6494028
2 5 28 82 185 374 731 1434 2842 5621 10916 20572 37405 65522 110687 180728 285978 439741 658772 963758 1379785
27 49 80 126 197 310 504 885 1731 3696 8158 17757 37162 74103 140767 255956 449312 771177 1316772 2284435 4111174
-9 -14 -19 -24 -29 -34 -39 -44 -49 -54 -59 -64 -69 -74 -79 -84 -89 -94 -99 -104 -109
6 15 27 46 76 121 185 272 386 531 711 930 1192 1501 1861 2276 2750 3287 3891 4566 5316
10 9 8 12 42 163 524 1407 3284 6886 13297 24100 41622 69352 112641 179837 284062 445903 697366 1087532 1690458
0 9 24 44 68 105 193 433 1055 2544 5865 12837 26717 53066 100980 184780 326266 557651 925302 1494426 2354850
10 12 10 4 -6 -20 -38 -60 -86 -116 -150 -188 -230 -276 -326 -380 -438 -500 -566 -636 -710
8 20 45 89 168 331 691 1470 3073 6209 12068 22530 40306 68775 111098 168065 234382 294482 323003 304787 309948
24 49 89 155 273 496 928 1779 3491 7003 14260 29127 58966 117310 228381 434731 810146 1481285 2663507 4719187 8250799
19 33 62 128 264 514 933 1587 2553 3919 5784 8258 11462 15528 20599 26829 34383 43437 54178 66804 81524
8 22 53 122 270 578 1193 2355 4413 7810 13019 20456 30543 44436 66599 111605 219725 490109 1149268 2691985 6174015
26 50 82 123 185 303 566 1175 2531 5351 10805 20662 37428 64454 105987 167132 253688 371816 527492 725693 969259
14 35 80 158 278 449 680 980 1358 1823 2384 3050 3830 4733 5768 6944 8270 9755 11408 13238 15254
11 11 15 23 35 51 71 95 123 155 191 231 275 323 375 431 491 555 623 695 771
6 16 24 35 58 96 141 187 289 723 2341 7266 20135 50173 114468 242916 485416 922018 1676862 2936893 4976496
11 20 49 110 227 453 898 1768 3424 6485 12017 21877 39339 70262 125339 224493 405397 739562 1361669 2521064 4668871
20 37 80 158 285 497 885 1648 3160 6035 11176 19837 33870 56674 96069 171621 331201 685379 1474871 3198556 6854496
4 6 20 55 138 338 805 1841 4037 8544 17608 35600 70923 139390 269951 514014 960066 1755866 3141164 5494709 9400256
8 13 34 90 208 430 841 1627 3186 6356 12910 26629 55545 116404 243087 501667 1015960 2008922 3867653 7245316 13228060
3 16 37 69 124 232 465 1001 2269 5236 11921 26249 55390 111764 215933 400645 716343 1238504 2077229 3389565 5395104
24 45 85 166 322 598 1063 1847 3218 5732 10517 19791 37764 72135 136467 253806 462004 821311 1424917 2413252 3992990
7 24 56 109 189 302 454 651 899 1204 1572 2009 2521 3114 3794 4567 5439 6416 7504 8709 10037
6 6 15 43 91 159 276 558 1303 3152 7405 16728 36804 80099 174024 377639 814012 1729858 3600691 7309097 14436681
14 20 37 71 127 210 320 440 518 446 41 -965 -2917 -6200 -11160 -17968 -26410 -35584 -43483 -46441 -38417
12 17 16 12 25 120 460 1409 3724 8883 19602 40622 79965 151215 278256 505768 922388 1709889 3242580 6278524 12310953
9 9 10 7 -6 -23 -1 179 775 2311 5872 13776 30987 67865 145228 303374 617945 1227749 2383562 4533485 8470988
9 11 14 19 43 131 362 843 1689 2997 4835 7291 10709 16508 29705 65926 169073 452107 1184316 2966327 7062159
4 19 44 77 112 138 134 62 -137 -530 -1130 -1722 -1448 2152 15406 53958 155715 410547 1025294 2459060 5690975
17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57
28 38 41 31 8 1 117 624 2070 5435 12324 25277 48475 89589 164469 308195 599485 1212145 2520288 5309464 11194667
1 4 2 -6 -13 14 174 709 2139 5482 12592 26654 52881 99464 178832 309285 517069 838968 1325494 2044762 3087143
-1 15 45 97 186 335 592 1078 2095 4347 9373 20396 44024 93710 196770 408372 838760 1704980 3427198 6805400 13340371
24 49 98 179 297 454 662 979 1576 2850 5634 11665 24741 53576 118484 266044 599328 1336819 2921754 6216539 12835689
21 43 91 177 313 527 903 1662 3307 6861 14233 28753 55923 104437 187529 324714 543993 884599 1400367 2163817 3271045
10 20 48 110 232 449 817 1461 2691 5227 10583 21669 43679 85342 160622 290962 508176 858102 1405138 2237792 3475386
11 35 84 169 305 523 890 1537 2706 4864 9012 17463 35603 75523 162993 350202 738357 1517321 3035288 5922273 11310317
5 16 36 79 164 317 575 988 1620 2577 4149 7249 14465 32206 74610 170076 371463 771142 1522162 2866763 5173298
23 47 91 180 355 676 1237 2209 3932 7082 12944 23827 43662 78829 139264 239902 402517 658025 1049321 1634726 2492125
15 23 27 34 62 157 432 1136 2766 6255 13310 27042 53131 101922 192141 357660 660775 1220785 2279451 4353200 8580138
22 35 50 71 109 182 315 540 896 1429 2192 3245 4655 6496 8849 11802 15450 19895 25246 31619 39137
19 46 99 184 301 445 609 789 991 1240 1591 2142 3049 4543 6949 10707 16395 24754 36715 53428 76293
16 35 78 161 304 532 886 1455 2451 4374 8370 17012 36007 77877 169678 368610 792378 1676029 3474614 7042651 13938682
11 21 37 74 161 344 684 1257 2179 3705 6498 12267 25210 55211 124765 283528 637855 1408801 3042715 6416976 13214939
28 50 82 125 194 336 661 1391 2939 6053 12112 23759 46217 89871 175017 340071 654974 1241980 2306406 4180161 7380828
16 33 52 76 116 194 346 625 1104 1879 3072 4834 7348 10832 15542 21775 29872 40221 53260 69480 89428
13 19 43 102 215 403 689 1098 1657 2395 3343 4534 6003 7787 9925 12458 15429 18883 22867 27430 32623
23 28 25 23 41 115 318 793 1799 3774 7427 13883 24921 43365 73712 123109 202823 330384 532621 849855 1341561
8 13 31 81 190 392 739 1348 2529 5075 10857 23969 52827 113862 237783 479848 936198 1769113 3245075 5790809 10074060
5 -1 -3 1 24 102 309 788 1831 4088 9089 20476 46745 107008 242462 538106 1162045 2433793 4938737 9713831 18540218
23 36 67 128 238 432 765 1304 2096 3100 4082 4498 3433 -276 -7530 -17782 -26795 -22876 18957 145468 436960
19 19 10 -13 -55 -121 -216 -345 -513 -725 -986 -1301 -1675 -2113 -2620 -3201 -3861 -4605 -5438 -6365 -7391
13 22 35 63 127 273 594 1257 2533 4828 8713 14951 24519 38623 58704 86433 123693 172546 235183 313855 410783
15 29 62 138 301 623 1211 2210 3808 6273 10109 16538 28739 54658 112833 243745 531201 1142472 2405599 4965114 10110423
22 31 40 45 47 68 173 508 1375 3376 7669 16390 33306 64775 121100 218375 380932 644509 1060270 1699819 2661361
16 37 69 115 199 383 781 1560 2922 5084 8336 13405 22681 43553 96491 233174 574927 1390866 3252030 7329342 15962906
25 37 46 52 55 55 52 46 37 25 10 -8 -29 -53 -80 -110 -143 -179 -218 -260 -305
-2 -1 16 58 135 261 456 747 1168 1759 2564 3628 4993 6693 8748 11157 13890 16879 20008 23102 25915
7 17 54 130 269 530 1052 2143 4445 9217 18788 37242 71407 132230 236630 409931 688987 1126121 1794010 2791658 4251609
15 31 72 160 334 671 1314 2518 4741 8835 16445 30812 58307 111210 212522 404027 759535 1406459 2560962 4585380 8082232
24 33 42 51 60 69 78 87 96 105 114 123 132 141 150 159 168 177 186 195 204
-5 -7 8 61 189 455 970 1944 3787 7293 13979 26755 51348 99453 195748 393249 805935 1675617 3503846 7302341 15051147
11 20 46 108 230 441 775 1271 1973 2930 4196 5830 7896 10463 13605 17401 21935 27296 33578 40880 49306
11 12 23 66 175 396 787 1418 2371 3740 5631 8162 11463 15676 20955 27466 35387 44908 56231 69570 85151
15 22 38 68 118 206 383 768 1612 3433 7323 15646 33567 72250 155262 330921 695341 1434220 2896652 5722340 11055780
3 7 20 59 150 322 611 1085 1914 3548 7156 15669 36147 84904 198134 453125 1009261 2185081 4599544 9425143 18831724
5 15 27 42 71 139 295 632 1326 2724 5557 11438 23947 50845 108404 229791 481678 998568 2056522 4234421 8765038
30 44 56 72 112 216 447 889 1638 2784 4382 6410 8712 10924 12381 12003 8158 -1500 -20220 -52372 -103696
16 22 30 43 71 138 296 646 1378 2880 6037 12959 28588 64067 143715 319587 702164 1525018 3279356 6987931 14747917
5 -1 -10 -24 -33 3 180 683 1836 4211 8897 18122 36552 73767 148641 296637 581375 1112247 2070344 3745532 6588173
-5 3 30 90 209 447 946 2018 4291 8943 18077 35324 66803 122611 219053 381840 650467 1083915 1767680 2821894 4409941
1 -6 -22 -51 -92 -122 -67 239 1107 3058 6900 13817 25470 44110 72703 115067 176021 261546 378958 537093 746504
19 35 71 138 255 454 787 1341 2267 3829 6479 10964 18471 30816 50683 81919 129891 201911 307735 460142 675599
5 1 -4 -15 -36 -60 -48 122 773 2679 7552 18927 43690 94632 194650 383626 729701 1347765 2429692 4293397 7461472
22 47 84 133 194 267 352 449 558 679 812 957 1114 1283 1464 1657 1862 2079 2308 2549 2802
27 39 50 67 106 190 350 637 1153 2109 3918 7331 13624 24844 44122 76061 127207 206611 326490 502995 757094
21 36 62 113 217 419 794 1493 2869 5767 12110 25974 55446 115785 234945 463719 895201 1702826 3214226 6051331 11387971
-4 11 40 84 152 276 534 1089 2268 4728 9788 20048 40471 80195 155561 295458 551743 1021562 1897525 3580679 6928437
-3 -5 -7 -9 -11 -13 -15 -17 -19 -21 -23 -25 -27 -29 -31 -33 -35 -37 -39 -41 -43
21 43 73 123 229 467 976 1988 3865 7143 12583 21229 34473 54127 82502 122494 177677 252403 351909 482431 651325
19 29 34 46 94 224 497 985 1765 2911 4484 6520 9016 11914 15083 18299 21223 23377 24118 22610 17794
8 20 32 44 56 68 80 92 104 116 128 140 152 164 176 188 200 212 224 236 248
13 9 14 36 82 168 347 777 1871 4603 11095 25687 56799 120029 243083 473279 888469 1612225 2833960 4834202 8014380
25 52 95 155 233 330 447 585 745 928 1135 1367 1625 1910 2223 2565 2937 3340 3775 4243 4745
3 -1 -2 20 104 313 751 1601 3198 6178 11813 22782 44894 90788 187635 392864 825918 1731880 3607877 7451423 15241457
11 18 34 74 172 382 776 1446 2531 4313 7458 13519 25868 51283 102484 201989 387747 721100 1297730 2262360 3828100
8 9 20 59 166 424 993 2158 4401 8543 16094 30140 57443 113004 229225 473103 976710 1988685 3957728 7663297 14414036
8 17 43 97 193 355 637 1160 2170 4121 7787 14407 25867 44923 75469 122854 194252 299089 449531 661037 952981
5 18 52 121 242 433 719 1158 1897 3263 5891 10909 20287 37707 70876 137305 277557 583511 1255976 2720254 5860036
26 48 79 117 160 206 253 299 342 380 411 433 444 442 425 391 338 264 167 45 -104
4 20 64 149 286 484 750 1089 1504 1996 2564 3205 3914 4684 5506 6369 7260 8164 9064 9941 10774
5 3 -2 -7 4 66 232 572 1184 2228 3986 6935 11795 19479 30826 45940 62887 75417 69278 16573 -132522
29 46 64 77 76 47 -27 -150 -260 -81 1250 6043 19894 55385 139172 325018 716889 1508424 3047842 5940189 11200546
7 31 76 154 286 522 977 1884 3677 7145 13741 26179 49495 92794 172036 314672 568255 1018307 1827378 3319972 6160648
19 43 90 171 309 555 1000 1776 3052 5057 8209 13520 23625 45116 93448 202656 443653 957187 2010888 4094557 8074321
14 31 63 137 309 692 1505 3161 6436 12799 25035 48359 92299 173720 321469 583243 1035418 1796727 3046839 5051069 8192641
-7 -9 1 45 169 453 1023 2063 3818 6573 10587 15954 22359 28711 32700 30500 17219 -10581 -47711 -63885 29897
5 8 18 46 107 216 385 636 1070 2070 4761 11892 29330 68346 148806 303230 581419 1054940 1820164 2997730 4725213
0 12 32 64 133 307 740 1752 3974 8606 17870 35802 69654 132452 247836 459451 849236 1572432 2922448 5446084 10138507
15 22 48 120 277 570 1062 1828 2955 4542 6700 9552 13233 17890 23682 30780 39367 49638 61800 76072 92685
-1 8 36 92 185 324 518 776 1107 1520 2024 2628 3341 4172 5130 6224 7463 8856 10412 12140 14049
24 54 114 233 454 838 1483 2582 4571 8460 16502 33454 68859 141115 284789 564103 1098634 2113702 4040682 7716703 14777228
20 25 26 22 13 13 87 421 1430 3916 9320 20183 41055 80282 153373 289016 539288 996203 1817478 3265284 5762801
9 14 30 68 146 310 661 1381 2749 5136 8966 14628 22322 31820 42121 50977 54265 45178 13206 -57124 -187782
15 29 57 109 202 360 614 1002 1569 2367 3455 4899 6772 9154 12132 15800 20259 25617 31989 39497 48270
1 -3 -11 -24 -42 -62 -67 -1 281 1125 3361 9019 23021 56870 136134 314735 700845 1501645 3097193 6156590 11811100
15 40 76 138 251 454 820 1509 2883 5740 11784 24555 51208 105772 214907 427910 834275 1595448 3004280 5598992 10382837
9 21 53 124 274 582 1207 2466 4963 9783 18765 34868 62644 108832 183087 298858 474429 734137 1109781 1642236 2383286
5 8 7 2 -3 0 23 82 197 392 695 1138 1757 2592 3687 5090 6853 9032 11687 14882 18685
17 32 48 73 137 316 778 1868 4250 9118 18486 35601 65661 117400 207006 367840 673662 1291711 2598975 5427196 11561076
2 8 10 15 40 116 298 695 1555 3470 7810 17562 38853 83592 173896 349294 678160 1275444 2329586 4142553 7188278
10 19 34 65 132 270 540 1046 1958 3541 6190 10471 17168 27336 42360 64020 94562 136775 194074 270589 371260
10 18 18 9 -7 -25 -37 -32 4 88 240 483 843 1349 2033 2930 4078 5518 7294 9453 12045
12 28 55 106 203 370 630 1008 1533 2219 2990 3512 2955 -59 -6445 -12294 4101 115235 521500 1722951 4891122
7 11 18 46 125 297 616 1148 1971 3175 4862 7146 10153 14021 18900 24952 32351 41283 51946 64550 79317
-4 2 13 29 50 76 107 143 184 230 281 337 398 464 535 611 692 778 869 965 1066
1 1 3 6 16 56 181 502 1224 2706 5573 10986 21362 42224 86628 185139 407435 908045 2021984 4462911 9729426
18 33 64 121 214 363 613 1050 1822 3197 5745 10819 21640 45488 97833 209864 442106 909229 1825714 3590277 6941170
5 18 44 95 192 363 652 1159 2143 4239 8878 19090 41095 87619 185057 389110 818618 1727421 3653857 7725842 16273119
+3
View File
@@ -0,0 +1,3 @@
0 3 6 9 12 15
1 3 6 10 15 21
10 13 16 21 30 45
+44
View File
@@ -0,0 +1,44 @@
import re
def main():
with open("9-input.txt", 'r') as file:
lines = file.readlines()
values = []
for line in lines:
values.append(get_value(line))
summerize = 0
for v in values:
summerize += v
print(summerize)
def get_value(line: []):
values = [int(digit) for digit in re.findall(r'-?\d+', line)]
values.reverse()
history = []
history.append(values)
for i, arr in enumerate(history):
if all(value == 0 for value in arr):
break
m = []
history.append(m)
for ii, val in enumerate(arr):
if ii + 1 < len(arr):
diff = arr[ii+1] - val
m.append(diff)
history.reverse()
for i, arr in enumerate(history):
if i == 0:
arr.append(0)
else:
last_value = arr[len(arr) - 1]
next_value = last_value + history[i-1][len(history[i-1]) - 1]
arr.append(next_value)
last_index = len(history) - 1
input_value = history[last_index][len(history[last_index]) - 2]
last_value = history[last_index][len(history[last_index]) - 1]
print(f"{input_value} -> {last_value}")
return last_value
if __name__ == "__main__":
main()
@@ -0,0 +1 @@
['AAAAA', 'JJJJJ', 'AAAAJ', 'JAAAA', 'JJJJ2', '2AAAA', '2JJJJ', 'Q2Q2Q', 'QQQJA', 'T55J5', 'T3Q33', 'KK677', 'KTJJT', 'Q2KJJ', 'T3T3J', '32T3K', 'J345A', '2345A', '2345J']
+70
View File
@@ -0,0 +1,70 @@
import re
import time
from concurrent.futures import ProcessPoolExecutor
row_cache = {}
def main():
with open("/Users/samuelenocsson/dev/advent-of-code/5-test-input.txt", 'r') as file:
start_time = time.time()
seed_string = file.readline()
lines = file.readlines()
lines_count = len(lines)
digits = list(map(int, re.findall(r'\d+', seed_string)))
next_index = 0
for idx, line in enumerate(lines):
numbers = [int(digit) for digit in re.findall(r'\d+', line)]
row_cache[idx] = numbers
with ProcessPoolExecutor() as executor:
futures = []
for i in range(0, len(digits), 2):
first, first_range = digits[i], digits[i + 1]
print(f"{first} -> {first + first_range}")
end_range = first + first_range
for s in range(first, end_range):
if s % 100000 == 0:
elapsed = time.time() - start_time
print(f"{s - first} done in {elapsed} seconds")
futures.append(executor.submit(get_location, lines_count, s))
next_index += 2
location = min(f.result() for f in futures)
print(f"Closest location {location}")
end_time = time.time()
elapsed_time = end_time - start_time
print(f"Elapsed time: {elapsed_time} seconds")
def get_location(nrLines, seed):
init_seed = seed
new_seed = seed
fast_forward = False
for i in range(0, nrLines):
mappings = find_numbers(i)
if len(mappings) > 0 and fast_forward:
continue
if len(mappings) == 0:
fast_forward = False
continue
source, destination, _range = mappings
if source <= seed <= source + _range:
diff = seed - source
new_seed = destination + diff
fast_forward = True
return new_seed
def find_numbers(idx):
return row_cache[idx]
if __name__ == "__main__":
main()
+12
View File
@@ -0,0 +1,12 @@
def nextCharIsSymbol(line, index):
for i, char in enumerate(line[index:], start=index):
if not char.isdigit():
return True
return False
# Example usage:
my_line = "416.........................559...............417...............785.......900.......284...........503...796....992.........................."
my_index = 3
result = nextCharIsSymbol(my_line, my_index)
print(result)
+64
View File
@@ -0,0 +1,64 @@
# day1.py
from base import AoCBase
from typing import List
import re
class Day1(AoCBase):
def __init__(self):
super().__init__(1) # Pass the day number to base class
def parse_input(self) -> List[int]:
reg = r"(\d+)\s+(\d+)"
raw = self.raw_data.strip().split("\n")
data = []
for line in raw:
match = re.search(reg, line)
if match:
one = int(match.group(1))
two = int(match.group(2))
data.append([one, two])
pass
return data
def part1(self) -> int:
result = 0
row1 = []
row2 = []
for tuple in self.data:
row1.append(int(tuple[0]))
row2.append(int(tuple[1]))
pass
row_sorted1 = sorted(row1)
row_sorted2 = sorted(row2)
distance = 0
for i in range(len(row_sorted1)):
distance += abs(row_sorted1[i] - row_sorted2[i])
pass
result = distance
return result
def part2(self) -> int:
result = 0
row1 = []
row2 = []
for tuple in self.data:
row1.append(int(tuple[0]))
row2.append(int(tuple[1]))
pass
for i in range(len(row1)):
n = row1[i]
count = row2.count(n)
result += n * count
return result
if __name__ == "__main__":
solution = Day1()
solution.solve()
+80
View File
@@ -0,0 +1,80 @@
import numpy as np
from base import AoCBase
from typing import List
class Day10(AoCBase):
def __init__(self):
super().__init__(10) # Pass the day number to base class
def parse_input(self) -> List[str]:
"""Override with specific parsing for this day."""
return self.raw_data.strip().split("\n")
def part1(self) -> int:
result = 0
trail_map = np.array([list(row) for row in self.data]).astype(int)
starting_points = np.argwhere(trail_map == 0)
for i in range(0, len(starting_points)):
visited = set()
print(starting_points[i])
trails = find_trail(trail_map, starting_points[i], visited)
result += trails
print("found", trails)
return result
def part2(self) -> int:
result = 0
trail_map = np.array([list(row) for row in self.data]).astype(int)
starting_points = np.argwhere(trail_map == 0)
for i in range(0, len(starting_points)):
visited = None
print(starting_points[i])
trails = find_trail(trail_map, starting_points[i], visited)
result += trails
print("found", trails)
return result
def find_trail(trail_map, point, visited) -> int:
trails = 0
if visited is not None and (point[0], point[1]) in visited:
return 0
if visited is not None:
visited.add((point[0], point[1]))
number = trail_map[point[0], point[1]]
print(point[0], point[1])
if number == 9:
print("found")
return 1
next_number = number + 1
shape = trail_map.shape
from_row = point[0] - 1
to_row = point[0] + 2
from_col = point[1] - 1
to_col = point[1] + 2
subset = trail_map[
max(0, from_row) : min(shape[0], to_row),
max(0, from_col) : min(shape[1], to_col),
]
# print(subset)
next_point = np.argwhere(subset == next_number)
if len(next_point) == 0:
return 0
for i in range(0, len(next_point)):
row = next_point[i][0] + max(0, from_row)
col = next_point[i][1] + max(0, from_col)
if col != point[1] and row != point[0]:
continue
trails += find_trail(trail_map, (row, col), visited)
return trails
if __name__ == "__main__":
solution = Day10()
solution.solve()
+89
View File
@@ -0,0 +1,89 @@
import math
import numpy as np
from base import AoCBase
from typing import List, Dict, Tuple
from re import findall
import cProfile
division_cache: Dict[int, Tuple[int, int]] = {}
digits_cache: Dict[int, int] = {}
class Day11(AoCBase):
def __init__(self):
super().__init__(11) # Pass the day number to base class
def parse_input(self) -> List[str]:
"""Override with specific parsing for this day."""
return self.raw_data.strip()
def part1(self) -> int:
regex = r"(\d+)"
numbers = findall(regex, self.data)
data = np.array(numbers).astype(int)
data = self.blink(data, 25)
return len(data)
def part2(self) -> int:
regex = r"(\d+)"
numbers = findall(regex, self.data)
data = np.array(numbers).astype(int)
data = self.blink(data, 40)
return len(data)
def blink(self, data, blinks):
for i in range(blinks):
arr = np.array(data)
# Handle zero separately as it has special behavior
arr[arr == 0] = 1
# Calculate number of digits for all elements
digit_counts = np.vectorize(lambda x: math.floor(math.log10(abs(x))) + 1 if x != 0 else 1)(arr)
# Find indices of numbers with an even number of digits
even_digit_indices = np.where(digit_counts % 2 == 0)
# Iterate over these indices, split the numbers, and replace them
new_data = []
for idx in even_digit_indices[0]:
n = arr[idx]
num_digits = digit_counts[idx]
first_half, second_half = split_number_in_half(n, num_digits)
new_data.append(first_half)
new_data.append(second_half)
# Handle the rest of the numbers that do not meet the splitting condition
for idx in range(len(arr)):
if idx not in even_digit_indices[0]:
new_data.append(arr[idx] * 2024 if arr[idx] != 0 else 1)
data = new_data
return data
def count_digits(arr):
return np.vectorize(lambda x: math.floor(math.log10(abs(x))) + 1 if x != 0 else 1)(arr)
precomputed_divisors = {i: 10**i for i in range(1, 20)} # Adjust the range as needed
def split_number_in_half(number, num_digits):
key = (number, num_digits)
if key in division_cache:
return division_cache[key]
half = num_digits // 2
divisor = precomputed_divisors.get(half, 10**half)
first_half = number // divisor
second_half = number % divisor
division_cache[key] = (first_half, second_half)
return first_half, second_half
if __name__ == "__main__":
solution = Day11()
#solution.solve()
cProfile.run("solution.solve()")
+43
View File
@@ -0,0 +1,43 @@
from base import AoCBase
from typing import List
import numpy as np
class Day12(AoCBase):
def __init__(self):
super().__init__(12) # Pass the day number to base class
def parse_input(self) -> List[str]:
"""Override with specific parsing for this day."""
return self.raw_data.strip().split("\n")
def part1(self) -> int:
result = 0
data = np.array([list(row) for row in self.data])
unique_values = np.unique(data)
print(unique_values)
for value in unique_values:
indices = np.argwhere(data == value)
edges = set()
for i in range(0, len(indices)):
if i == 0:
edges.add(indices[i])
continue
return result
def part2(self) -> int:
result = 0
for line in self.data:
pass
return result
if __name__ == "__main__":
solution = Day12()
solution.solve()
+92
View File
@@ -0,0 +1,92 @@
from base import AoCBase
from typing import List
from re import findall
class Day2(AoCBase):
def __init__(self):
super().__init__(2) # Pass the day number to base class
def parse_input(self) -> List[str]:
"""Override with specific parsing for this day."""
return self.raw_data.strip().split("\n")
def part1(self) -> int:
result = 0
regex = r"(\d+)"
safe_increment = 3
for line in self.data:
valid = True
matches = findall(regex, line)
numbers = list((int(match) for match in matches))
previous = None
current = None
is_increase = numbers[0] < numbers[len(numbers) - 1]
for number in numbers:
previous = current
current = number
if previous is None or current is None:
continue
if (
abs(previous - current) > safe_increment
or previous == current
or is_increase != (previous < current)
):
valid = False
break
if valid:
result += 1
return result
def part2(self) -> int:
result = 0
regex = r"(\d+)"
safe_increment = 3
for line in self.data:
valid = True
matches = findall(regex, line)
numbers = list((int(match) for match in matches))
is_increase = numbers[0] < numbers[1]
valid = self.is_safe(safe_increment, numbers, is_increase)
if not valid:
for i in range(0, len(numbers)):
n_copy = numbers.copy()
n_copy.pop(i)
is_increase = n_copy[0] < n_copy[1]
valid = self.is_safe(safe_increment, n_copy, is_increase)
if valid:
break
if valid:
result += 1
else:
print(f"Invalid numbers: {numbers}")
return result
def is_safe(self, safe_increment, numbers, is_increase):
previous = None
current = None
valid = True
for i in range(0, len(numbers)):
previous = current
current = numbers[i]
if previous is None or current is None:
continue
if (
abs(previous - current) > safe_increment
or previous == current
or is_increase != (previous < current)
):
valid = False
break
return valid
if __name__ == "__main__":
solution = Day2()
solution.solve()
+48
View File
@@ -0,0 +1,48 @@
from base import AoCBase
from typing import List
from re import findall
class Day3(AoCBase):
def __init__(self):
super().__init__(3) # Pass the day number to base class
def parse_input(self) -> List[str]:
"""Override with specific parsing for this day."""
return self.raw_data.strip()
def part1(self) -> int:
result = 0
regex = r"mul\((\d{1,3},\d{1,3})\)"
data = self.raw_data.split("/n")
for line in data:
matches = findall(regex, line)
for match in matches:
n = match.split(",")
result += int(n[0]) * int(n[1])
pass
return result
def part2(self) -> int:
result = 0
regex = r"(mul\((\d{1,3},\d{1,3})\))|(do(?!n't))|(don't)"
skip = False
matches = findall(regex, self.data)
for match in matches:
if match[2] != "":
skip = False
elif match[3] != "":
skip = True
if match[1] != "" and skip is False:
n = match[1].split(",")
result += int(n[0]) * int(n[1])
return result
if __name__ == "__main__":
solution = Day3()
solution.solve()
+68
View File
@@ -0,0 +1,68 @@
from base import AoCBase
from typing import List
from re import findall, search
import numpy as np
class Day4(AoCBase):
def __init__(self):
super().__init__(4) # Pass the day number to base class
def parse_input(self) -> List[str]:
"""Override with specific parsing for this day."""
return self.raw_data.strip().split("\n")
def part1(self) -> int:
result = 0
data = np.array([list(row) for row in self.data])
count = 0
for i in range(0, 2):
rot = np.rot90(data, i)
print(rot)
r = self.count(rot)
print(i, r)
count += r
for ii in range(-len(rot) + 1, len(rot)):
diag = np.diagonal(rot, ii)
print(diag)
rr = self.count(diag)
print(ii, rr)
count += rr
result = count
return result
def count(self, data):
flat = data.flatten()
s = "".join(flat)
return s.count("XMAS") + s.count("SAMX")
def part2(self) -> int:
data = np.array([list(row) for row in self.data])
dict = {}
count = 0
print(data)
re = r"(MAS|SAM)"
for ii in range(-len(data) + 1, len(data)):
diag = np.diagonal(data, ii)
flat = diag.flatten()
s = "".join(flat)
matches = search(re, s)
if matches is not None:
idx = matches.start()
dict[idx] = ii
pass
for k in dict:
k
return 0
if __name__ == "__main__":
solution = Day4()
solution.solve()
+34
View File
@@ -0,0 +1,34 @@
from base import AoCBase
from typing import List
from re import findall
import numpy as np
class Day6(AoCBase):
def __init__(self):
super().__init__(6) # Pass the day number to base class
def parse_input(self) -> List[str]:
"""Override with specific parsing for this day."""
return self.raw_data.strip().split("\n")
def part1(self) -> int:
result = 0
data = np.array([list(row) for row in self.data])
return result
def part2(self) -> int:
result = 0
for line in self.data:
pass
return result
if __name__ == "__main__":
solution = Day6()
solution.solve()
+70
View File
@@ -0,0 +1,70 @@
import numpy as np
from base import AoCBase
from typing import List
from re import findall
from itertools import chain
class Day7(AoCBase):
def __init__(self):
super().__init__(7) # Pass the day number to base class
def parse_input(self) -> List[str]:
return self.raw_data.strip().split("\n")
def calc(self, sum, numbers, target) -> List[int]:
if len(numbers) == 0:
return sum
sum_1 = self.calc(sum + numbers[0], numbers[1:], target)
sum_2 = self.calc(sum * numbers[0], numbers[1:], target)
return [sum_1, sum_2]
def calc_part2(self, sum, numbers, target) -> List[int]:
if len(numbers) == 0:
return sum
sum_1 = self.calc_part2(sum + numbers[0], numbers[1:], target)
sum_2 = self.calc_part2(sum * numbers[0], numbers[1:], target)
sum_str = str(sum) + "" + str(numbers[0])
sum_3 = self.calc_part2(int(sum_str), numbers[1:], target)
return [sum_1, sum_2, sum_3]
def part1(self) -> int:
result = 0
regex = r"(\d+)"
for line in self.data:
numbers = findall(regex, line)
target = int(numbers[0])
numbers = list(map(int, numbers[1:]))
sum_1 = self.calc(0, numbers, target)
arr = np.array(sum_1)
print(arr.flatten())
targets = np.argwhere(arr == target)
if len(targets) > 0:
result += target
return result
def part2(self) -> int:
result = 0
result = 0
regex = r"(\d+)"
for line in self.data:
numbers = findall(regex, line)
target = int(numbers[0])
numbers = list(map(int, numbers[1:]))
sum_1 = self.calc_part2(0, numbers, target)
arr = np.array(sum_1)
print(arr.flatten())
targets = np.argwhere(arr == target)
if len(targets) > 0:
result += target
return result
if __name__ == "__main__":
solution = Day7()
solution.solve()
+130
View File
@@ -0,0 +1,130 @@
import numpy as np
from base import AoCBase
from typing import List
class Day8(AoCBase):
def __init__(self):
super().__init__(8) # Pass the day number to base class
def parse_input(self) -> List[str]:
"""Override with specific parsing for this day."""
return self.raw_data.strip().split("\n")
def part1(self) -> int:
result = 0
np.set_printoptions(threshold=np.inf)
data = np.array([list(row) for row in self.data])
u = np.unique_values(data)
dict = {}
antennas = {}
for val in u:
if val == ".":
continue
indices = np.argwhere(data == val)
for idx in indices:
row, col = idx
antennas[(row, col)] = val
for i in range(0, len(indices)):
idx_2 = indices[i]
row, col = idx - idx_2 # -1 ,3
row_2, col_2 = idx_2 - idx # 1, -3
if row == 0 and col == 0:
continue
a_r, a_c = idx + np.array([row, col])
a2_r, a2_c = idx_2 + np.array([row_2, col_2])
dict[(a_r, a_c)] = (a_r, a_c)
dict[(a2_r, a2_c)] = (a2_r, a2_c)
shape = data.shape
for k in dict:
if k[0] >= 0 and k[1] >= 0 and k[0] < shape[0] and k[1] < shape[1]:
data[k[0], k[1]] = "#"
result += 1
s = np.array2string(data, 250)
v = replace_chars(s)
with open('output.txt', 'w') as f:
f.write(v)
return result
def part2(self) -> int:
result = 0
np.set_printoptions(threshold=np.inf)
data = np.array([list(row) for row in self.data])
u = np.unique_values(data)
dict = {}
antennas = {}
shape = data.shape
for val in u:
if val == ".":
continue
indices = np.argwhere(data == val)
for idx in indices:
row, col = idx
antennas[(row, col)] = val
for i in range(0, len(indices)):
idx_2 = indices[i]
row, col = idx - idx_2 # -1 ,3
row_2, col_2 = idx_2 - idx # 1, -3
if row == 0 and col == 0:
continue
a_r, a_c = (0, 0)
a2_r, a2_c = (0, 0)
curr_idx = idx
curr_idx_2 = idx_2
while True:
a_r, a_c = curr_idx + np.array([row, col])
a2_r, a2_c = curr_idx_2 + np.array([row_2, col_2])
dict[(a_r, a_c)] = (a_r, a_c)
dict[(a2_r, a2_c)] = (a2_r, a2_c)
print(a_r, a_c)
print(a2_r, a2_c)
curr_idx = np.array([a_r, a_c])
curr_idx_2 = np.array([a2_r, a2_c])
idx_ob = is_index_in_bounds(data, a_r, a_c)
idx_ob_2 = is_index_in_bounds(data, a2_r, a2_c)
if (not idx_ob) and (not (idx_ob_2)):
break
for k in dict:
if k in antennas:
continue
if k[0] >= 0 and k[1] >= 0 and k[0] < shape[0] and k[1] < shape[1]:
data[k[0], k[1]] = "#"
result += 1
result += len(antennas)
s = np.array2string(data, 250)
v = replace_chars(s)
with open('output.txt', 'w') as f:
f.write(v)
return result
# Function to check if an index is within bounds
def is_index_in_bounds(array, row, col):
num_rows, num_cols = array.shape
return 0 <= row < num_rows and 0 <= col < num_cols
def replace_chars(input_string):
# Replace single quote
updated_string = input_string.replace("'", "")
# Replace open square bracket
updated_string = updated_string.replace("[", "")
# Replace close square bracket
updated_string = updated_string.replace("]", "")
# Remove spaces
updated_string = updated_string.replace(" ", "")
return updated_string
if __name__ == "__main__":
solution = Day8()
solution.solve()
+102
View File
@@ -0,0 +1,102 @@
import numpy as np
from base import AoCBase
from typing import List
class Day9(AoCBase):
def __init__(self):
super().__init__(9) # Pass the day number to base class
def parse_input(self) -> List[str]:
"""Override with specific parsing for this day."""
return self.raw_data.strip()
def part1(self) -> int:
result = 0
n = list(self.data)
numbers = np.array(n).astype(int)
d = []
id = 0
for i in range(0, len(numbers)):
for j in range(0, numbers[i]):
if i % 2 == 0:
d.append(id)
else:
d.append(None)
if i % 2 == 0:
id += 1
array = np.array(d)
none_pos = np.argwhere(array == None)
pos = np.argwhere(array != None)
for i in range(0, len(none_pos)):
if none_pos[i][0] > pos[len(pos) - 1 - i][0]:
break
# print("swap", none_pos[i], pos[len(pos) - 1 - i])
array[[none_pos[i][0], pos[len(pos) - 1 - i][0]]] = array[[pos[len(pos) - 1 - i][0], none_pos[i][0]]]
# print(array)
none_pos = np.argwhere(array == None)
for i in range(0, none_pos[0][0]):
result += array[i] * i
return result
def part2(self) -> int:
result = 0
np.set_printoptions(threshold=np.inf, linewidth=np.inf)
n = list(self.data)
numbers = np.zeros(len(n), dtype=np.uint8)
d = [numbers, n]
d = np.array(d)
id = 0
for i in range(0, len(numbers)):
if i % 2 == 0:
d[0, i] = id
id += 1
else:
d[0, i] = '.'
for i in range(d.shape[1] - 1, 0, -1):
if i % 100 == 0:
print(i)
size = d[1, i]
val = d[0, i]
if val == '.':
continue
positions = np.argwhere(d[0] == '.')
for pos in positions:
if pos >= i:
continue
dot_size = d[1, pos][0]
if dot_size >= size:
d = np.insert(d, pos, [[val], [size]], axis=1)
new_dot_size = int(dot_size) - int(size)
d[1, pos + 1] = new_dot_size
d[0, i +1] = '.'
break
print(d)
idx = 0
pos = 0
while d.shape[1] > idx:
val = int(d[1, idx])
id = d[0, idx]
if id == '.':
pos += val
idx += 1
continue
id = int(id)
for j in range(1, val + 1):
print(id, '*' , pos)
result += pos * id
pos += 1
idx += 1
return result
if __name__ == "__main__":
solution = Day9()
solution.solve()
+22
View File
@@ -0,0 +1,22 @@
import numpy as np
# Your input data as a list of strings
data = [
"MMMSXXMASM",
"MSAMXMSMSA",
"AMXSXMAAMM",
"MSAMASMSMX",
"XMASAMXAMM",
"XXAMMXXAMA",
"SMSMSASXSS",
"SAXAMASAAA",
"MAMMMXMMMM",
"MXMXAXMASX"
]
# Convert each row into a list of characters, then stack them into an array
array = np.array([list(row) for row in data])
# Display the array
print(array)
+30
View File
@@ -0,0 +1,30 @@
from base import AoCBase
from typing import List
from re import findall
class Day3(AoCBase):
def __init__(self):
super().__init__(2) # Pass the day number to base class
def parse_input(self) -> List[str]:
"""Override with specific parsing for this day."""
return self.raw_data.strip().split("\n")
def part1(self) -> int:
result = 0
for line in self.data:
pass
return result
def part2(self) -> int:
result = 0
for line in self.data:
pass
return result
if __name__ == "__main__":
solution = Day3()
solution.solve()
+35
View File
@@ -0,0 +1,35 @@
# base.py
from pathlib import Path
from typing import Any
from abc import ABC, abstractmethod
class AoCBase(ABC):
def __init__(self, day: int):
self.day = day
self.raw_data = self.read_input()
self.data = self.parse_input()
def read_input(self) -> str:
"""Read input file."""
return Path(f"inputs/day{self.day}.txt").read_text()
@abstractmethod
def parse_input(self) -> Any:
"""Parse the input data as needed."""
pass
@abstractmethod
def part1(self) -> Any:
"""Solve part 1."""
pass
@abstractmethod
def part2(self) -> Any:
"""Solve part 2."""
pass
def solve(self):
"""Solve both parts and print results."""
print(f"Day {self.day}")
print(f"Part 1: {self.part1()}")
print(f"Part 2: {self.part2()}")
+14
View File
@@ -0,0 +1,14 @@
# Parse the grid into a dictionary of (y,x):c
data = open("inputs/day4.txt").readlines()
H, W = len(data), len(data[0])-1
grid = {(y,x):data[y][x] for y in range(H) for x in range(W)}
# Part 1 - Find anything that says 'XMAS'
TARGET = "XMAS"
DELTAS = [(dy,dx) for dy in [-1,0,1] for dx in [-1,0,1] if (dx!=0 or dy!=0)]
count = 0
for y, x in grid:
for dy,dx in DELTAS:
candidate = "".join(grid.get((y+dy*i, x+dx*i),"") for i in range(len(TARGET)))
count += candidate == TARGET
print("Part 1:", count)
+1000
View File
File diff suppressed because it is too large Load Diff
+53
View File
@@ -0,0 +1,53 @@
45678701021256787218432154301232100012334301023456789
32569892430543298909845067210145621965421012310545869
01210743549612187610756778143296534874310123458930978
12323651258703066525643889050387546789210234567821567
01434210367012178434512918761236695694391349650131054
12544303438124569232101109678945784321487658743232343
43695496549433450143001234532034653210156961234589787
94786987834342100154519873541128763165432870234671096
85677889929854343267610565690639454076501210165692345
76012870010767256998701234788748348987432101156787654
01043961171258107887898345659654239858901101089810123
32154552987349016576987454564980108765432232123209874
43960143476987657607876523875676501678921349854112365
54871232564890548510965014934189432578900458963012453
69890121465431239423454876821054329657811467874501412
78781230656322102347623945498765018746324320189432303
45610945567212121098510130340121201235435410234534564
44327876438901010101498321233290345110346761809621875
34387654323432129812367321044789876011289898918760976
45297890012343456703455433445602345895670767823451987
56187781201278914567526932563211056734321296744589854
67096654302107803498017801074787654321234585430076763
78945109213456012332101301985698543210987676121125892
21032238376788768945432452394987650121789678032434981
32561247487699854876983345401276345430678549140123470
23470056794521003123476236982345036781565432101210565
14980129873430412001569107810034129092634307870389874
05691234562541343432018098941125678104321216921010123
06788765101632234589127657832103543219450325432167012
12109453210762103678934566543012354308765014703458983
43898344789899872100129875414983989412894327812565410
56701235692198561091223014305894876543781016945678320
12345106541085432782014323216765321789692345238769801
01416787632176306654105450125601450694547654199654432
12109898501201217653296961234702364543498703080123569
01234549654323898741787870149810676032107012678034078
67899678760015677230765487654321980121978710569985127
58908707871234982101896398923450890120879623450276434
43211216910123878982363210110961051234566542141105589
52890345034987965985476545607872340345651033032234676
01761212125675654876983432787401456978762122345897655
10354305430234503210012301294301967869887831056798587
23487416521105012342121345385210876778896990987123496
96596547012276109653010256106321236569045781234012345
87432108983489298764560187287810345652134650965421004
76545017698548345675078894396923456743221045874540218
89632123087632210982189123405410567892100038973234389
56749834128901043983458016512321098754321122980198476
43898765439456712276567087695632347665430101076567567
32109650169329803125690198787541056578920122345445898
78980543278019874034787239645670567810110233410336765
65211230165216565129876543532789436921898398561221234
34302321254305653210210123401890125432765487652310123
+1
View File
@@ -0,0 +1 @@
125 17
+10
View File
@@ -0,0 +1,10 @@
RRRRIICCFF
RRRRIICCCF
VVRRRCCFFF
VVRCCCJFFF
VVVVCJJCFE
VVIVCCJJEE
VVIIICJJEE
MIIIIIJJEE
MIIISIJEEE
MMMISSJEEE
+1000
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -0,0 +1,6 @@
;({where()+'what()mul(445,324)#what()select()(+mul(430,603)why()@^&why()<mul(991,973)what()*~where()mul(320,361)from()how()mul(39,679)+what(856,339)what()why()*{+mul(73,323)from() [select()-,what()!(mul(133,891)?,mul(996,200)who()when()mul(668,190)mul(537,572)who()who(){why()mul(455,630)!$!from()do()@%-!when()who()-:mul(77,345)@(/when()^~mul(759,479)})++(+</mul(112,700) why()>'$>{!*]mul(11,880)#?$##:@mul(653,180)mul(343,172)^*({]!&!@~mul(121,364)>(~ mul(905,512)!''&;{%?why()mul(253,82)%&mul(173,725)''[mul(948,412)])how()select()) don't()where()mul(688,386)mul(798,885)+:&:)mul(139,466)from();what()'*( +,mul(337,913)!?,why(315,219)why()]@'when()mul(299,848)?-mul(404,810)don't()who()[$@$)mul(562,587)/%%mul(930,204)?$?why()mul(671,431)]from()#+(who()who();mul(467,198)select()what(748,331)from()[when()%@:do();mul(648,804))~where()who()mul(433,801)':how();@!'^{mul(294,95)&?mul(394,740)((}:select())mul(627,328)?how()who()>+where()select()!mul(726,536)^what()select(603,656)#@<!)why()@mul(665,531)<#&( where()@why()when()/mul(651,419)when()who()@mul(251,901)mul(917,673)mul(139,942)<(-]don't()>];~~mul(100,802)where()what()mul(675,411)$((+how();/%mul(858,719)from()-do()what()*]~;mul(873,971)//%mul(78,89)~'from()&where()@from()mul(308,52)mul(959,448)why()#%select()#(mul(379,76)}how(678,794)mul(575,884)how())*do()mul(829,831)why()how(999,884)who()where()^(@mul(686,468)}from() how()&<&mul(886,603)</?,mul(171,272)how()-%where()mul(766,411)#$^&,why()'),,mul(763,590)from()who()> <when()#mul(486,962){[+how()&:+mul(572,266)}@!~who())%select()mul(15,796) 'how()!$select()mul(147,232)(@; ;mul(267,231)do()who()/mul(859,800)how()& select(396,707)-mul(291,826)&what()mul(512,787)how()?{%'#<?don't() *@!mul(767,135)+}~,how(){,)mul(727,699)-/}[-mul(566,179)%@$- !^mul(193,546)&}from(),mul(705,766):>+;]?from()why()*do()&~!;mul(247,653)-mul(828,136)when()select()from()mul(258,842)what()?<)#];mul(517,650)!%+'~-mul(215,28)*-^*mul(810,676)select()%who():where(){>who()when()mul(632,298)how()'how()from()mul(823,219)what()'@^who():when()mul(400,833)from()$%'/,[(]mul(216,848),#!/#:mul(725,486) }~~<(mul(564,772)where())mul(819,487)]:)-&/}mul(71-(mul(732,511)~ (where()<?^&mul(650,977);?{what() ]where()mul(81,106),$%mul(909,962)@,how()@mul(452,162)@mul(468,658)select()~?('~**mulwhen()]:,<mul(8,295)^from()[when()$~]mul(697,476)+why()<how()*who()~from()}mul(755,649)&^!}select()mul(298,890)why()<'&mul(912,689^what()+do()*when()mul(577*/what()-<#how();!^mul(131,588)how(461,8)from()]!mul(331,224)%<$<^:]~{mul(918,263)select()<~;mul(374,998)^mul(182,130)how(61,655)<%who()who()&,what(743,368)why()mul(623,620)'?why()mul(783,314#select()-when()]mul(153,641)~)</^*where()mul(148,613how(),]%/*<why())from()mul(663,15)where()(:*mul(90,830)where())>:- mul(773,414)what()how(581,907)[how(218,409)?//mul(94,697))<what()!- <]!mul(530#when()~)who(),)select()@/mul(373,912)mul(684,83)>)?<-#>mul(89,657)mul(385,928)%what()why(467,355)&->mul(757,734) ]mul(517,244)]select()when(253,938)^>/'&(mul(232,10)mul(665,886&mul(880,285)
what()#where()&$mul(310,297)%>why()^<mul(768,599where()mul(999,433)^who()select()(?>what()]mul(593,941^where(),-select()mul(937,169),+!why()>when()([>+do()%]select()why()mul(104,652)[*;^who()-}#(mul(963,537)mul(579,212)select()--{from(644,349)+:select(857,111)mul(531,515)(&,%how()}$:mul(989,356){;{,))}'mul(142,281)&@~!]mul(289,916)%+when()from()/$:mul(551,55)from()from()$how();;why()}mul(738,532)< (~mul(547,99))how()>mul(159,62)(^*who()where()@@who()*^do()^'*&what()mul(34,665)-do()%@how(732,538)mul(459,928)what()*mul(407,795)+^+@{[:[mul(695,539)mul(359,852)mul(132,930)mul(729,877)/^(^mul(727,452)(<why() {(<?mul(390,950);when())what(398,903))when()^'()mul(998,792)why()when()(! $mul(583,453)>mul(782,665)when()>*mul/^mul(688,251),(mul(117,838)mul(313,301)??from():mul(918,351)>mul(513,285](what()&why()~what()who()mul(493,941)(%who():mul(298,591)]:select()&/mul(91,464)}(%*,{-mul(316,801)/$+'~select()[!do()?>%,mul(253,555)*@when():why()>what()mul(511,598)/where() /<from()&-^mul(947,949)$/mul(20,922)@>#'?mul(193,147)mul(693,462)>}~}mul(942,134)%mul(545,298)select(883,847)'&;what()why()])]select()mul(932,859),;*who()mul[what()where()/&%mul(479,587)%?{<-^]select()#where()mul(992,583)who()[&[&[mul(714,106){<mul(505,757)%(][mul(579,833)>% where())]~'mul(158,893)/select(){when()~select()*:from()[don't()@select()>~^$how()%}mul(262,794)who()/how()mul(856,695)}(;who()+from()what()mul(203,385)select()@<^;?>-';mul(409,500);why()+<who())> mul(721-{where();{mul(419,384)when()from()where()+~%select()mul(23,108)/~}select(932,457)/[from()mul(381,237)(mul(249,569)mul(332,31)from()select()$mul(760,792){'why()%< @mul(378,678)-/mul(146,764)+:[why()mul(262,148)*<mul(121,174):why()&how(307,405)select()#^^when()mul(392,80)$,:]!>?,who()%mul(209,306)$]*@from()>(;how(),mul(992,237)from()};+{<mul(670,900)#^{$mul(661)how()*do()~)'who()%mul(151,599)what() [where()%#mul(673^(who()do()mul(544,71)${?:}}&mul(662,996) /}+do()-when()}[!{mul(609,652)?where() why()do()&what()select()@mul(335,388)$[mul(213,850)how()^mul(495,85)-+mul(391,227)why()![^/'how()mul(248,277)mulwhen(){who()] mul(488,770)from()^'*from()[where()mul(700,675)mul(97,173)mul(284,269)!why(205,144)]-[[<mul(490,718)<$?~+mul(931,41)who()#(*what()}[mul(148,888){( >who()&when()!mul(941,631))~what()$what()]mul(528,570)what()select()when()<#}what()don't()>*#-mul(379,986)!()]select(9,153)mul(942,395)><#?what(313,440)where()@how()from(){mul(663,775)*^what()[mul(584,62)when();$#mul(270? ])>&select(){ ^how()mul(837,91)what()where(){%^&!!mul#>^~<'#]-%mul(160,825)?*&%)({!'$mul(488,459)mul(466,879)#,!%+ ](+%mul(371,785)-(,mul(884,509)<,select();mul(423,954))what()[what()what()~mul(548,650)']don't()where()<?-:%>[]'mul(892,161)who();)]?mul(54,246)!-mul(140,679)who()@)@mul(193,36)mul(64,972)&;+)@mul(152,414)where()when(748,355)mul(778,929)*<[&*$mul(549,697),mul(183,897)when()/':&%:&#mul(428,989)mul(220,961)}do()what()$what(536,484)*[]:$select()}mul(943,870)'mul(658,52)->(^!;select()^)$mul(474,140)where()mul(700,771)]^%>]^'mul(933,512)
:]$^do()select()^~]who()& ^}mul(142,82)(?{mul(324,299) ^&@mul(426,954)*why()mul(535,943)'^)*<]mul(540,959)~select(),how(770,994)select()mul(623,558)<why()why()}^]do(),!mul(953,55),#{mul(233,892)!}(mul(80select()where()'what()how(835,158)mul(802,151)+from()(from(128,497)what()*([mul(29,512)mul(92,69)%)?mul(702select(342,843)-(~>#mul(778,72)+-*where(631,115)how()mul(777,784):+mul(834,445)*-$do()mul(504,419)mul(760,788)%~why()-mul(861,519)},how()~*#mul(654,701)/;<how()< ?(mul(395,393)mul(229,309!&when()select()-mul(22,564)why()select()+#-who()}%do()when()~,mul(899,367)<,<){ mul(881,948)from(710,608)from();who()/mul(672,218)!$where()why():mul(156,654)how()why()*where()&when()#<#<mul(631,751):$-^:/mul(519,756)}select()<mul(994,484)#<#why()/mul(208,160)/~%}mul(982,443)don't()~mul(235,731)~what()}<$^{(mul(816,163)?who()who()select(),/&mul(200,800)'/?from(),mul(17,848)where())[,~!^]{mul(837,649)('# }](^mul(710,747),mul(43,339)):+[%what()/)mul(250,801)mul(177,503)~>/mul(765,616)}- ]why()!#mul(695,46)~!/,#~&mul(867,931)mul(69,230)<!-*who()+mul(953,132)]{from():* -:mul(981,205)how()from()how()where()+[mul(741,911)[{why()%?who(176,667)what()!mul(194,445)mul(970,761)select()mul(722,592)~*?what()[}*}mul(807,681)<--how()mul#~{,/'}mul(118,771)mul(217from()/;; where()mul(21,190)what(),when()#~[}mul(490,199)*mul(29,437)'&where();[when()where()&mul(437,931)?*/~what()where()@!where()where()mul(454,998)mul!when()what(283,438)from()mul(752,709)/:<*/do()from()what();<}<mul(20,583),$),mul(770,783)(!%-*mul(508,561)>/[?mul(937,711)+#;don't()-when()mul(287,875)who()>*^who()how()how(59,735)when()what()mul(642,627)&:from()how(){:mul(273,186)mul(513,893)<+when()'select()(mul(250,147)mul(944,800)&}/:}%don't()/when(763,491))&what()~mul(369,406)when()) [$<'mul(17,672)<mul(656,755)+{/])select()&mul(109,548)where()) mul(210when(573,420):why()%,$~mul(262,927)?(:{<%who()!^mul(92,518){mul(261,612)]-(mul(724,456)mul(887,115))/why()',?mul(732,96)-[ mul; mul(925,310)when()-:-what(),!*do()-}who()who()#how()>mul(882,623who()[)'[why())#'?mul(81,716)+ mul(447,640)mul(653,686)when()-!)*>']@mul(261where()(($(who()why()^~mul(513,546):?@',who()when()??[mul(133,831)what(642,114)- from()$mul(688,974)&mul(130,103)!+what(){&%)mul(208,734)@do()<(</-[how(),mul(600,588)$} where()@!+$mul(215,125) *,don't()</':select()select()&,select()^mul(335,926)mul(526,944)@+[,!where()(mul(357,677)[from()mul(29,462)what()@what()when()[mul(990,235))>$<>)%,-mul(184,818)mul(890,576)how()mul(837,954)'select()([;*)>,;mul(238,270)^^what()](/mul(850,817)^what()+'why()<](;mul(399,231)+how()when()-mul'when()*<+('->what():mul(57,595)+where()mul(61>{from()who())when()mul(20,581)^'?<+#mul(506,640)select()'[)&{^from()$mul(238,389)select()when(41,502)@what()[-where(),select()who()mul(330,955)~^/when(134,118)&<@%!mul(766,471)mul(292$select()what()^)}{mul(294,301)select()+mul(4,456);]what(270,427)/what(638,143)#mul(567,277)+~what()when()mul(291,92)&what()mul(883,529);}'+><from()@@mul(153,229)from(),,}::)$<when(903,784)do()[(^#mul(810,887)mul(127? ,+ !do()from()#what();select();'mul(573,461[[where()what();'#!/usr/bin/perl}!why()@^+%/where()-mul(151,714)#'{;'><mul(757,774)
don't():>>/;%^)mul(837,12)why()#[>@mul(180,108)<)^)-select()mul(790,366) mul(477,626)who();don't()what():>})>select()#,select()mul(970,250)+!why() (&+mul(702,494))-^when()>mul(365,357)who(823,464)>@from()when()~#mul(193,867[)$mul(59,73)what()/mul(150,669)$}who()why()why()?>+,mul(503,887)~!&&(:#&,}mul(770,232))mul(608,780)}what()>@where()mul(814,784)how();<from()%/where())mul(352,786)$mul(207,994)?&$%%&+from()-mul(109,408))what()~mul(814,457)select()<[mul(19,549)~)mul(917,930)[{^mul-mul(8,721);'+<[-do()from()mul(509,815)]&*who(487,114)?#who()(mul(821,706)/$why()from()'#;^mul(952,474)$mul(595 ($#how():who()$who()mul(191,64)when():why()mul(945,156)+mul(67,396)when()}mul(676,86)mul(983,709)@mul(302,19)*$select()&who()from()!??mul(109,820):select(229,939)@^!when()mul(775,689)mul(123,536)<{where():(:mul(744,643/^~'#where()<where()~mul(877,757)select()select()where()%$mul(964from()$why(){how(888,807)/{;mul(20,417)&from(931,370)mul(916,436)>mul(195,454)/]why()how()who()mul(119,155),^mul(840,203)'+]<};mul(307,495)#(who()what()$select()when()$;+mul(26,644)how()+;select(255,590)mul(531from()select()'mul(714,614),mul(325,872)<<[mul#}!:mul(394,222)@%what(588,571)-,:<&mul(400,422)-]do()what()how()#{&why()%when(466,904)~mul(851,835)~how()where()&*why(499,551)*mul(910,493),!what()>where(303,78),'select()%mul(625,527)mul(479,758)mul(327,98)mul(554,259)select()}mulwhy() !;]@'/mul(113,41)where()$how()*select()do()%'^]@mul(285,496)&select()do()[/!?/[mul(27,435),{;;from()?/{}^mul(918,36)!{? [![:mul(490,857)where()((,mul(428,611)-$,/><#(who()mul(456,409)when(369,358) :~+where()-(what()@mul(733,862)'@$(mul(131,879)from()~-$select()mul(734,484)from()what()what()mul(507,287)where(),why(284,579)>>!]from()who()mul(295,272)-mul(882,901)/]<-$^+#*mul(745]:when():<?from(317,30)how()%mul(789,365)]!]who()mul(893,528)!mul(53,733),'mul(608,702):?{select()don't(),>:$-where()how()<mul(43,408)mul(527,351)&/how()why()(:mul(902,966)$do()]?*~/how()mul(60,36)}+~@where()^mul(95,237)what()select()'who()what()-where()))}mul(954,748)$#from()from(),(*>/mul(898,313)do()<$why()!!</mul(821,96)-why()mul(200,701)/mul(421,170)[when())from()what()^:select(263,923)mul(718,787)$,^ > why(839,58)$,mul(788,713)from()+[what()}~#what()+do()[ $*where()~@!@+mul(603,956)when()mul(601,972)what(56,144)do():why(){mul(103,342))$>who()'mul(60,904){why()/)who()$mul(761,131)!&->when()mul(560,725)from()mul(818,250when())(<(#/-mul(387,817){ ;!-^mul(702,837)';don't() $}]@mul(461,199)$'where()~:from()from(171,996) }don't()/-??$}mul(994,543):#!why(),'>mul(442,181) ;!@%mul(601,317)+?-+$mul(909,275)when(296,190)when()select():->when(453,892)'mul(551,960)mul(507,289)what()when()+mul(671,135)select()+~from()}when(),why()/mul(121,912)from()#who()mul(799,631)mul(784,458),'do()::~+}how())mul(454,304)who()%what()select()what() what()~mul(94,667)mul(360,282)mul(528,823) *;;when()?~)mul(848,397)}[/^({/%mul(261,776)-from(),mul(726,676)$what()+)mul(641,845:+*#mul(729,810)!how())<mul(13,187)how()%#who())what()mul(587,161)where()?where()~when()'mul(280,145)~:!@)&why()mul(436,283)who()]mul(752,757):!>$/mul(352,322)how()from(156,362)(}>:$,])mul(784,187)
mul(989,116)what()? mul(240what()^&;;mul(154,827)^<don't();how()@#from()/?@,mul(445,633)from()how()+mul(546,175)why(),what()?[)what())!~mul(522,402):what()-mul(825,669)/~from())[&(from()mul(157,376)<*#from():,(%mul(957,617))why()&how()where(),,from(),mul(668,157)(},from()((:@'~mul(63,982)+;:<[ do();what()>@what()mul(254,522)select()how()'why()(?do()@}#where()mul(193,567)/mul(775,751)([]!what()>%(mul(788,585)&/,mul(475,307){when(140,109)-why()/mul(349,674)how()from()<$%when():where()#mul(227,383)when()%#-mul(711,505)what()why()#^<why()mul(43,231)/&:why()+/-/how()^don't()why()<>'}}why(){what()mul(717,303)how()>mul(760,51)%&-~)>!mul(674,136)mul(140,636),)~&-mul(908,30)mul(154,688):from()-when()<^#!?mul(417,70)%<from()?(>>do()~^--#'<@>>mul(354,115)~when()'what():from(354,427)>mul(279,257)mul(292,504):[{[who()('what()^mul(893,699)^+&)[//mul(753,807)><+])}~mul(957,644)$]]+how()~$mul(53,811)mul(447,226)select()mul(774,984)why()why()'![don't()+$where()>$&from(16,716)}?mul(252,848)]#&from(){mul(895,641)///when()#)mul(482,275)how()) )select()from(){mul(645,131)*));*+mul(266,281)%[mul(446,962):)< who();/mul(876,107)%*>mul(187,697)-how();select()$mul(962,372)mul(276,649)}what()!#select(),from()? who()mul(540,977)why()#}</&-[-from()mul(753,655)what(589,427)<{where()what()#mul(623,760){select() where()who()?$mul(26,86)(+[$,select()%<mul(877,970),do()&^<^from()#>why()-mul(527,726)!/select()%?mul(602,536)/?what()why() select()%/mul(926,882)why()who()-}*/mul(960,515) >~!?^!how()select()mul(597,249)what()/<@$~$what(708,877)/mul(871,408)mul(178,932)/why():why(541,591):why():$+%mul(107,703)[@*from();who()don't()? [>*mul(345,156)< ?];^)>from()select(549,167)mul(764,609)&where(32,545)#mul(35,321)<&when(241,647)/mul(414,62)[![how(243,208)-)mul(399,237)#'#+when(820,119)where()($mul(418,23)what()mul(618,231)$(mul(864,185)'#!^mul(730,572)#];what()$>};why(866,942)mul(196,426)($@where()where(),mul(51,66)from()[)#<;where()<:mul(504,489),@*when()why()mul(979,151),]@*^(^where(48,22)why()mul(910,862)mul(58,405)#>' ~from()when()mul(817,943)*(who()[<how()*what(251,66)mul(277,652))mul(669,16)%:from()why():[/[{*mul(727,589)-#:!mul(34,541)+mul(906,174)*+^[mul(112,617) what()+'how()do()#~+[what()when()^~/mul(203,659)when()[}select()'#mul(869,605)where()->[*%;+who():mul(140,620)~[mul(93,354),do()how()who(){how()'$-what()why()mul(542,872)<;mul(490,224)+*):}when() ]mul(840*]what()}('&mul(563,138)when()mul(298,803)+!'&#+~+mul(914,40)~<select(347,181)#mul&?~<mul(848,266)/~'#!?mul(436,708)>+how()mul(766,174){/#what()who()when()~)%don't()&where(){mul(587,419)'!don't()&where()'/+mul(629,54)$!!where()/what()*~mul(523,43)?where(686,184)#>%how()-; +mul(165<who()<where()[from()when()#select():from()mul(297,190)[&^-~/how()mul(441,676)what()mul(47,942)^+/$who()<]mul(4,166)/mul(257,565)&~$how()^#%&mul(446,402)where();:mul(900,590)-)>from()mul(137,486)(;}when()!?from()where()where()^mul(694,53)what()mul(631,877)(how()?/'@)-from()mul(711,927)+what()when()&how()mul(66,129)from())],}/$what()#mul(347>mul(691,91)mul(791,897)when()~ }-)mul(325,178)mul(105,565)^<*mul(193);;]how()mul(355,707)#{#%mul(27,653)
%how()how():?:mul(766,746)*@mul(364,566)-< who()(*':mul(999,344)*/select()--mul(672,593){how())<mul(73#)()@+mul(83,507) mul(373,176)who()^'('mul(584,620)what()#//!do()mul(103,225) ~;;'why()*~mul(187,119)+/]mul+(select()%mul(874,888)}when():how()mul(583,992)^~[[what()don't()() {from() ]]((mul(68,200)^?what()who()*[mul(932,283)['$mul(189,932)< ,mul(652,125))$how()where()how()^how()#]mul(501,335)!when():+%])!<mul(551,924)+,#why()) $mul(118,951)@])/'who()mul(858,212) who(){-how()!don't())mul(746,402)/%}where()mul(629,312)];*~#]mul(680,3)what()how()what()'}?'@where();mul(263,427)#$$from()-what()mul(698,847)#(;$!$<+mul;why())what())$select()mul(482,169)-where()mul(546,79)mul(796,632)how()select()when()&$/*mul(749,226)-%what()>(who()'/<when()mul(932,346)?where(),^^>mul(722,627)>-?mul(231,501)~}#!mul(694,751)when()how()- where(202,572)select() }*^mul(17,75):+'what(),&mul(413,505)mul(113,65)[-+{,[mul(83,722)((mul(475,980)mul(588,832):/;)what()/+mul(103,764)?{$:?{{+:select()mul(583,487)mul(757,133)why()??mul(47,54)<]>select()>^?$mul(201,196)$from()]^~#where()mul(494,817)]?//-#select()%+mul(444,319)%?from()mul(316,303)}-~'<<-when()when()mul(350,810)mul(557,674)~##(select()$mul(97,781)who()(>>' >!),mul(473,488)who(290,952)mul(33,630)why()>do():)<select()~ mul(571,144){mul(931,78)mul(200,845)how()#select(403,528)mul(741,613)mul(54,465)@;(<[>mul(267,367)+/who())^select()^from()$!mul(409,900)*what()[)]who())[+where()mul(309,751)~don't()!mul(165,206)mul(113,418)]from(),'&do()select()/*:)]!mul(272,138) mul(211,851)]/$mul(916,846)mul(203,199)mul(40,428){&*from()%mul(305,353)? >}where()<what()(mul(904,794)+$from()-,/{mul(712,685)@ what(628,776)why(){;:;-mul(909,11){<,,mul(287,272),?),>%mul(397,337)]!mul(352,23)@don't()where()^{from()mul(804,392)${<}!mul(392,298),>>mul(572,89)+why()$*;when())#where()$mul(458,495);mul(375,386)~from()mul(429,704),{*%select()$who()]mul(442,21)#why()@?!mul(659,81)when()<($%^&&don't()!mul(934,729)/<[:how(288,214)'mul(971,226);+!%!mul(465,736)/]&%&^what(),+mul(613,544)-/from()what() },<-!mul(906,152)[who()&when()select()mul(612,56)~&<')/!mul(247,423)from()[{&who()mul(979,442)[mul(319,494)~%/+mul(781,251);<>)who()%from()[from()mul(27,381)}+)what()%/select(),,mul(324,64)mul(938,422)how():@>}:%'/&mul(388,707)]@mul(98,712)~who()$%@?(what()from()who()mul(161,906)~where():#mul(198,30)why() ~!>how()['-who()mul(5,68)what()<%%{mul(829,126):,mul(509,883)mul(142,939)do()#>mul(53,112)!(what()/?do()(,how()%mul(523,469) who(){what()'/mul(356,713)~@;!~ ->mul(309,932)where()mul(93,190)where()select()){how()}why()mul(202,888))!,{{:what(),~mul(591,813)select()<&{[&mul(652,199)
+10
View File
@@ -0,0 +1,10 @@
MMMSXXMASM
MSAMXMSMSA
AMXSXMAAMM
MSAMASMSMX
XMASAMXAMM
XXAMMXXAMA
SMSMSASXSS
SAXAMASAAA
MAMMMXMMMM
MXMXAXMASX
+10
View File
@@ -0,0 +1,10 @@
....#.....
.........#
..........
..#.......
.......#..
..........
.#..^.....
........#.
#.........
......#...
+850
View File
@@ -0,0 +1,850 @@
426048: 425 608 69 88 1 282
1234: 8 53 21 2 611 1 538
3493064: 42 823 101 932 966
7851123: 81 52 937 7 9
109137611815: 9 4 9 1 9 5 13 97 18 1 4
143516213: 2 906 6 5 12 22 578 3 3
629453: 7 492 3 28 6 6 9 104
5423661: 5 2 8 8 91 4 6 7 3 40 8 6
18682395: 93 37 3 1 431 765 2
556488358421: 794 98 33 6 917 7
14604120: 89 13 65 703 17
51347: 24 9 908 8 9 3 6 36 41 6
1200264: 1 324 69 614 9 34 52
84467: 99 1 694 50 64
832680: 3 58 68 45 3
13238: 4 3 58 9 652
1505251: 3 24 97 1 29 669 5
28869324: 99 749 1 46 74
125890: 6 894 7 6 87 9 2
265251: 8 9 8 87 251
928664914: 4 7 6 8 664 8 2 9 1
103228624: 7 2 73 7 94 91 95 26
5765376: 442 85 4 41 8 742 8 4 8
101551004: 2 78 991 38 75 8 4
11531: 4 42 589 122 1
230639: 88 6 3 722 3 9 1
533796498: 66 80 3 2 101 4 5 2 501
8494148: 32 35 79 2 8 3 30 2 8
222246692: 23 41 13 94 970 689
9841934: 2 998 419 815 5 809
2186556: 51 9 9 660 4 2 9 8 69 7 3
11207789126: 1 9 425 1 68 5 9 2 293 9
33355203: 7 199 5 84 119 57
60424: 989 61 79 8 8
651253: 3 4 904 8 2 8 72 87 493
2099106644: 277 842 9 624 22
29145931: 3 6 15 3 7 9 70 6 1 1 6 5
63140: 8 79 61 77 82
720845730: 9 3 43 1 53 45 650 81
3030: 45 57 85 280 5 94
64316066: 7 6 7 422 14 953 37 4 2
31898201: 77 74 3 622 3 797
99024982725: 48 77 1 3 47 8 1 30 846
3086415: 5 139 1 6 1 8 2 24 2 3 6 9
1604915280: 2 7 652 74 321 7 18 4
1040: 316 22 7 3 4
792201: 748 7 22 488 99 493 4
1449102: 23 525 6 4 4 5 82
6672: 8 1 563 7 9 593 863 1 4
641235: 18 5 76 3 87 8 8 93 15
836: 399 2 31 7
2589888404878: 4 8 94 21 41 40 4 8 77
79158297957: 221 570 58 29 795 6
94656: 64 547 254 223 87
158670130: 2 9 3 4 32 2 645 2 6 5
1172900: 5 624 9 5 3 69 38
18570144924: 6 3 570 144 926
11809188: 63 26 801 77 7 9 90
17569711116: 9 9 2 2 156 793 3 109 4
72864: 8 2 3 1 5 3 99 8 4 72
30090677155977: 38 89 11 5 217 41 9 79
54186: 5 418 6
536456640: 1 53 273 27 3 1 35 52
1324: 568 47 2 45 5 2 40
255466537: 98 49 133 4 82 56
108593: 440 931 5 635 54
274562: 18 4 88 12 3
2310: 168 125 6 551 1
158226796: 4 2 1 71 56 18 67
227860: 632 36 2 68 5
254276307: 211 927 13 62 57 90
969151: 96 75 1 79 6 608 1 856
1381920960: 329 7 7 6 4 3 5 51 5 4 3 8
57750433: 466 22 1 43 6 1 131
2039463: 8 532 4 2 2 4 3 59 245 1
924: 4 2 42 57 2 23
984: 9 5 1 3 4
3490: 32 9 8 5 7 7 18
764789: 47 91 3 83 341 2 942 4
8761312983: 1 5 1 645 2 56 981
49375245: 46 16 94 4 67
1371731088: 258 80 58 98 119 1 6
1691074: 3 653 36 8 2 4 61 153
237984: 3 60 942 4 84 514
8487: 3 836 6 3 7
1302665: 8 327 850 4 8 848 637
338504789434: 9 7 96 4 27 58 1 7 7 431
4375: 5 320 13 87 62
39114592: 24 74 32 3 53 53 8 58 9
55211: 1 2 5 261 3 6 6 3 873 6 5
3930310: 6 727 89 883 77
105416741: 8 6 2 7 830 2 7 81 29 72
1864306: 752 37 67 22 76
10308245: 460 6 22 56 243
8724688: 61 143 1 688
802716549428: 81 991 6 5 494 30
4542460: 5 11 52 818 924
3187936924: 8 9 54 879 356
63545: 1 459 7 429 71
117919: 9 76 202 28 91 1
3743973: 74 82 5 41 5 269
861952: 57 558 68 7 2
3334911: 668 16 39 8 255
66798536: 27 9 931 6 92 65 3 3
8653262: 4 82 5 326 2
658062508: 5 97 94 2 5 6 9 3 55 6 7
22128516: 111 222 898
1200278: 40 5 6 269 1 8
8492254: 465 206 452 28 74 6
3976640: 97 49 2 8 340
6598260668: 7 20 3 459 9 9 9 66 8
349711968: 699 417 1 4 1 9 50 4 4 8
4360998090: 46 474 98 40 5 9 586 2
38968452095: 4 8 59 12 7 172 6 592
7435934408: 521 8 34 8 32 2 2 2 7 79
3601746: 772 4 711 1 61 7
1037835487: 2 33 58 143 836 7
5238563720270: 5 238 5 5 4 9 720 27 2 5
73195290: 1 5 3 442 4 46 2 7 74 9
39219: 7 612 3 676 2 9 5 58 3 3
171333389699: 63 45 681 1 9 868 3 96
5938: 5 554 315 59 8
26921: 93 28 3 36 843
462492: 370 38 563 73 443
372492502: 9 1 521 5 407
252499564: 6 1 676 72 5 91 736 44
9089304: 8 405 786 1 28
22290929687: 18 8 255 512 849
496884960: 62 9 691 5 3 52 2 418 1
52469758: 7 21 96 244 80
1915494: 72 667 81 32 1 5
9240: 10 4 9 8 48 21
1229174: 39 965 1 6 16 2 676 73
63520233: 629 6 20 20 2 31
40053664: 520 36 298 72 207
31513519: 5 63 13 52 1
73259497328: 105 380 5 4 81 92 2 82
380149: 5 2 9 59 84 52
3532752: 75 6 40 8 7 9 1 4 7 7 48
735865836: 2 63 65 3 220 42 58
1036899: 1 972 63 89 6
119723575: 885 89 2 8 95 775
3394585738: 1 14 571 49 3 218 264
43184: 9 47 91 47 18 728
49179361: 3 2 358 1 27 7 8 5 1 35 1
60589: 51 9 55 8 31
3853: 376 9 454 6 9
97218628: 727 238 7 1 5 3 562 67
573: 3 18 8 47 306
2673281: 37 17 850 5 31
2519097323: 4 4 5 97 433 8 9 95 142
6282472: 46 1 691 942 3 472
1997842: 25 474 46 4 4
21463827009: 6 23 2 74 68 7 1 540 5 6
52876: 55 96 7 3 3
5458: 97 56 11 8 8
306: 4 93 5 1 3
2246440404358: 35 2 97 944 68 53 358
2156122429948: 627 6 8 625 3 796 3 1 9
705471450: 257 448 47 1 450
12086441200083: 60 4 322 5 3 8 5 5 20 86
95185977895: 98 5 36 209 966
66643: 1 3 7 1 6 43
243331: 233 9 57 6 756
12661228256: 590 33 4 6 7 5 4 774 8 4
1100: 141 1 952 1 5
10510801045: 69 2 2 9 86 5 9 1 76 28 3
9888464534: 77 6 246 98 7 74 967 5
361718875114: 2 97 4 725 12 1 5 186 6
106512316: 40 7 2 8 449 818 536
7588010: 64 694 772 1 291
991: 23 4 7 1
417: 6 45 7 75 65
15920852: 55 93 8 8 3 3 5 8 5 7 8 9
699: 4 8 55 43 589
35097279829: 4 6 2 2 7 9 58 9 5 7 982 9
108684: 5 6 2 62 283 1 6 4 9 2 1 6
35276: 28 575 4 57 677
8895075: 5 175 18 8 8 171
40618: 7 219 38 7 558 54 46
55909321: 4 4 4 6 3 2 41 705 8 3
176390408: 496 6 61 6 8 3 64 5 2 5
407788355: 40 778 7 603 3 747
102608197: 81 5 348 5 7 26 1 4 237
8020532: 9 9 9 1 969 8 4 5 8 884
2581035: 66 5 388 83 7
802185122: 561 993 4 360
3277848705: 9 6 53 9 95 6 7 11 7 6
134464957445: 1 493 1 9 495 74 44
229748861160: 67 46 3 205 234 518
2940111322: 37 12 917 589 22
18670960793: 9 6 5 3 9 8 261 3 1 46 4
1142150721: 5 16 55 5 212 5 5 2 18 3
22196443505: 815 786 45 77 4 1
573211: 2 377 7 24 18 9
4843: 3 6 9 44 4 82 8
302249666485: 3 194 57 134 54 717
662063: 5 3 2 1 624
132572: 6 8 36 82 57 2
3864582: 2 3 24 7 582
1690: 102 691 4 128 765
1209: 19 8 7 7 96
126089845: 7 5 8 5 98 736 3 7 9 1 7 6
46487320: 7 1 664 7 249 71
39486: 46 405 1 87 160
2736552: 3 28 8 83 7 28 537
2172301065: 63 91 618 3 55
523522: 93 1 67 362 522
986428764: 985 978 446 4 722 43
12315880: 9 29 96 8 470
3984391: 39 843 92
5689708: 5 4 5 7 7 576 6 157 6 19
64505661: 64 1 505 397 262
227515138: 227 5 1 513 5
215361445: 3 83 63 820 93 86 2 46
34003007060: 651 993 2 526 60
16267: 920 7 1 2 834 6 58 69
267374268991: 6 89 73 9 8 826 8 71 59
112166154: 10 2 93 5 66 155
135: 9 1 5 42 43
11248: 70 1 423 8
2911500: 7 1 379 10 647
65618: 984 65 686 971 1
1423917: 23 24 26 9 18 1 3 99
1436633024645: 2 84 134 9 2 9 9 8 79 8 2
280912: 935 3 3 62 52
102593598: 442 2 326 89 3 4 1 7 75
38611: 3 9 503 9 6 7
36060: 5 8 1 16 4 601
28487: 73 691 6 37
721930973: 72 18 830 479 70
36324778803: 800 100 3 2 26 454
70492231245: 571 990 211 5 591
801607886: 2 79 33 888 80 7 886
15442400: 28 69 999 3 72 157 8
354682: 8 40 1 3 5 5 4 8 3 18 9 1
11718044: 9 180 31 20 43
2292878: 7 56 82 229 425
8686510: 37 390 2 64 1 9 291 4 3
47239: 2 77 52 4 9 9
23755253: 2 3 1 14 707 19 10 22 1
20814560: 68 8 44 536 1 3 2 4 2 2
431195040: 3 579 696 74 1
29632103424: 32 66 6 7 6 62 898
3417: 8 81 2 28 869
10513496180: 211 3 56 7 2 6 7 135 47
4575903869: 45 6 2 3 9 1 903 8 6 9
481562: 2 15 946 50 5 9 3
23919714428: 27 8 335 3 2 6 39 4 2 6
7227024325: 393 870 603 211 22
113705615: 16 7 76 94 561 4
36627744: 31 879 122 467 76
9682305217682: 3 1 3 8 5 9 739 1 1 835 1
1883: 19 215 8 1 14
310865765704: 4 5 93 47 8 3 6 8 5 703 4
65640: 2 3 9 5 671 1 89 9 3 9 3
34615688: 8 581 1 9 1 6 5 699 4 90
2874960: 136 2 372 936 55
125692: 11 4 89 28 2
21607840833966: 9 9 950 1 75 96 871 39
23335608: 45 75 54 7 51
6234: 20 18 819 73 6 654
250181: 92 8 4 338 50 7 4
38566354: 9 7 120 611 37
62704469: 2 8 9 71 5 66 44 5 6 10
385850: 5 8 8 7 2 8 63 6 3 678 3 2
115032285: 8 150 96 7 913 15 21
24871: 8 3 270 600 1
77113465: 7 555 723 1 6 7 465
6231: 5 8 5 956 5
388: 4 291 1 18 4 72
63870451184: 1 1 3 2 911 508 8 293
961: 5 9 1 8 4 9 87 5 10 5 26 1
651002: 2 861 685 2 84 5 2
2999: 9 328 41 3 3
697540864632: 38 79 4 2 726 8 4 316 2
13399549: 3 1 11 73 8 59
3562090: 866 1 6 83 674
7828907: 74 2 706 87 2 10
2386854: 1 2 6 68 78 5 2 4 3 5 5 4
81760686: 706 5 7 1 6 6 2 7 2 19 87
214797: 8 9 3 421 8 1 3 4 1 9 42 9
54427336: 30 712 8 173 53 79 73
1053341344949: 65 569 3 712 238 4
1448736525566: 160 97 9 6 4 6 8 57 563
2123419597390: 606 83 8 9 9 6 6 9 7 393
123978240: 336 8 4 9 4 6 8 7 7 2 8 60
35148535: 2 7 4 48 565 8 4 2 8 9 5 2
204124802990: 9 630 13 340 36 7 583
539960: 44 66 196 25 960
37179596269: 5 9 63 806 153 6 267
46944: 256 517 694 4 8
164447918604: 3 3 5 68 2 239 59 3 20 1
606512067: 202 5 85 25 2 1 7 4 6
582: 6 82 4 78 1 8
358489335615: 4 8 36 290 49 3 356 12
37968920318: 619 787 27 6 9 203 1 8
45917891663: 6 97 6 743 4 91 665
56974260612: 681 192 73 598 894
1433362936: 23 81 301 2 938
13387282062: 71 5 209 7 382 7
1440477: 3 9 37 3 66 4 2 667 58 9
54297: 87 359 12 77 5 2 7
45930136: 75 180 3 3 8 378 104 8
15415060: 60 9 86 5 795 94 115
152568: 9 1 61 5 68
27460988: 2 74 60 488 501
1057969: 284 4 4 93
2426020: 856 7 13 202 2
49096: 6 5 24 2 68
9219: 345 9 3 85 8 23 15 5
502450092967: 1 142 17 6 6 1 85 589
252469069: 478 8 7 1 57 8 66 59
24272: 1 8 8 7 4 752 9 6 1
156972819: 21 9 858 968 3
4435814457: 77 9 8 8 6 1 14 460
7029: 57 3 5 6 971
7053569543: 70 52 914 2 653 531 9
19649102: 9 7 9 5 22 545 4 839 94
267089242: 3 5 3 83 8 2 342 7 29 5 7
93765: 40 945 53 957 47
815253659: 48 97 581 700 8 52 7
14381: 70 1 91 2 1
6727770: 8 5 1 2 7 47 96 2 4 2 9 38
488959: 12 7 770 5 7
444850: 57 3 7 68 6 350
359101435530: 819 36 14 3 143 553 2
255298640: 5 7 2 336 9 6 25 6 226 8
627971804: 91 69 71 723 81
376876294: 603 625 5 15 779
4870224: 8 32 3 2 68 8 93
2921378615: 7 3 1 1 7 7 272 2 3 953 5
25762: 22 3 475 1 288
9334: 8 9 6 1 5 125 42 364
61711944: 453 61 26 6 4 8 3
31159097: 62 1 5 953 605 32 97
1486721291: 178 87 68 96 9
164195070864: 93 879 40 795 8 4 22
209: 2 83 46
448419: 16 657 642 341 4
2213729487: 7 9 9 7 1 33 6 6 7 457 3 4
826: 83 91 642 8 2
69845916113: 4 6 87 39 6 1 6 62 78 77
420247390: 7 8 70 5 9 6 6 33 1 9 6 53
468391418: 1 5 4 363 885 7 3 9 6 3 8
730151: 729 320 7 816 9
6121517413: 707 9 6 6 4 4 6 43 6 9 3 4
1331520: 8 304 44 288 95
2651662: 24 755 9 34 1
55557168: 45 8 7 13 6 49 716 8
925030462: 453 992 2 8 8 64 4 2 3
22929993: 6 1 9 403 8 6 7 9 677 9 8
136079: 10 7 80 8 1
4018560: 24 2 115 4 182
155443251648: 1 89 7 9 6 2 2 819 48
47311914088: 1 739 4 9 498 7 71 7 4
12959675904: 7 558 529 98 1 84 64
117075505: 4 651 2 693 2 63 6 89 7
8663990338: 3 5 36 5 2 989 3 23 337
38598654357: 8 78 6 7 3 2 5 1 9 1 343
1066: 3 68 3 447 7
9763884: 4 8 11 4 806
2649: 710 3 76 94 1 3
97022: 6 5 4 84 77 2
4436743: 2 4 20 36 7 37 6
10887: 8 1 931 930 26
41289: 5 160 2 2 4
64001920: 561 4 3 61 38
4877046: 961 40 84 3 58
94551: 942 3 5 3 1
2348968: 234 86 3 6 8
4829697944: 5 51 4 9 7 8 687 122 8
1275687: 531 4 6 262 9 9
866: 5 3 7 3 8
62826: 1 6 1 1 6 2 634 84 491 7
234421278: 586 4 2 12 81
987: 5 81 3 31 864
1512712546: 9 8 7 63 7 125 47
81507: 1 4 800 69 38
6885843415: 743 5 546 570 926
28383880: 20 47 9 76 1 89 469
8399: 73 86 242 8 877 994
6734289681: 841 681 9 889
2487534047373: 259 5 3 948 9 974 101
11402873: 17 96 609 414 17 553
18904325600: 55 21 735 4 325 600
1335462451: 16 5 9 9 14 8 3 3 70 955
70253: 2 115 30 9 2 38
17112: 9 5 4 7 9 66 1 6 5 1 9 2
240212907: 4 9 83 31 381 71 8 21 4
1137902: 24 89 78 71 31
17115001: 8 9 5 100 978 2
8596391: 85 8 7 3 87 9 24 3 5 5 22
536020: 80 67 17
1999835: 8 241 881 8 790
91503776: 1 6 419 4 5 7 7 2 6 8 91 7
141043433: 470 5 59 6 4 796 1 2 3
662831: 69 96 6 5 31 9
2527482: 5 670 26 6 8 4 3 6 6 258
663617436: 3 8 420 90 66 91 7
5117396: 9 43 45 5 32 34 74
286833458: 299 976 59 956
1810904: 402 12 2 15 73 351 3
14755500281: 339 44 1 161 3 3 2 1 3 2
891738: 8 2 2 43 1 6 4 93 2 963
1431924: 1 32 3 124 9 92 4
18526: 572 3 33 7 71 27 4
204101449: 650 314 9 5 50
19637: 54 6 5 57 55
46435032: 4 5 706 87 84
3901884025: 21 5 80 167 377 335
1357110633: 798 3 2 85 633
368814453: 93 509 63 8 612
16783688: 4 9 9 417 4 972 5 31 9
12778007: 75 949 14 552 167
3103890: 775 4 3 89 3
746384: 52 14 91 74 5 8 305 9 8
1324077: 1 132 24 2 1 6 674 967
6907431: 203 9 3 7 2 6 3 6 30 4 3 3
291241150: 142 5 2 5 909 5 500 86
10416: 35 4 9 217
222786114772: 428 3 36 98 836 1 52
30956235: 5 263 130 3 193 37
1807890624: 973 24 27 1 688
70133160056: 822 711 9 1 4 2 6 5 5 5 7
882460946: 1 8 8 6 3 1 3 2 5 943 2 3
2371851: 8 27 50 5 890
40024680321: 1 8 5 7 65 5 4 38 941 3 7
487213: 29 9 661 697 9
740743860807: 77 75 6 2 46 134 812
17850: 20 9 9 26 83 5
83290948: 5 91 8 75 2 927
586005: 584 894 66 816 228
483120417: 3 3 72 4 50 99 4 17
21612195: 117 9 6 9 6 1 3 379 5 6 9
1146285425: 70 5 863 1 945 427
311680: 8 8 5 4 81 3 621 3 4 1 6 5
81: 2 5 2 4 1
1692432: 6 80 5 764 8 146
982802: 73 73 2 8 4 3 8 5 3 5 7 2
25409164560: 1 6 9 1 188 7 2 5 7 9 12 5
366260: 318 47 47 1 78 7
168240337: 5 944 11 6 9 9 4 3 5 2 67
156807: 47 4 8 456 80 7
14995745: 6 714 25 35 870
24780095: 8 15 5 5 4 7 67 4 3 7 11
104125: 557 482 2 22 2
1844501: 41 2 9 357 7 202 32 5
6275963892: 1 482 98 9 9 699 1 12 1
3890574408: 176 78 786 6 28
47467: 293 9 3 6 1
926285: 9 2 532 96 5
2209: 7 1 8 94 20 9
219763712: 294 7 62 184 8 8
1754288721: 344 99 440 155 814 9
531930: 49 85 694 65 6 900 85
1005239880: 1 733 9 94 6 997 2 4 60
462: 33 9 26 131 8
6132669: 9 52 546 4 6
14541: 30 6 1 8 8
49132039: 57 7 6 4 6 8 98 5 2 5 2 42
10597759252: 40 7 3 622 8 10 9 7 7 6 9
750879481848: 55 65 6 1 6 5 8 7 3 31 9 5
301540320: 46 510 83 819 8 795
25711201: 3 7 337 9 296 2 2 60 5 7
3131219615335: 6 1 51 20 21 9 615 3 35
190931: 6 6 9 7 836 2 1 7 6 1 552
39873482: 1 61 950 90 687
136495497599: 4 878 7 7 4 48 5 3 7 99 2
62: 5 9 3
4072901: 4 52 40 14 1 2 9 1 4 1 8 8
3639889: 665 7 2 540 6 46 7 1
44833: 8 910 6 472 1 8 3 672
226176: 2 65 275 30 608
100819083: 3 9 6 7 16 325 116 9 18
2124636580913: 5 382 61 9 6 580 91 1
18389: 71 5 6 4 6 2
74957687: 7 2 7 8 5 9 5 59 9 636 6
1935561104: 70 129 276 8 5 58 561
285412: 39 26 7 961 98 2
910425: 7 9 111 4 4 5 427
1868263488: 7 973 1 56 654 52
356: 9 9 7 64 4
121563: 2 3 84 6 25 566
11793880: 9 1 1 61 292 577
6433920: 50 265 4 8 4
757114712: 677 795 6 739 29 86 4
92196314: 91 427 769 314
3622: 9 5 32 3 9 8 9 20 65
748249: 41 5 3 5 3 9 1 101 4 810
57521100: 67 570 940 490 3
694140: 42 712 4 1 92
2584: 1 9 2 2 6 8 7 8 12 7 460 4
1299844: 72 4 567 8 8 47
4438062035: 7 710 541 133 8 1 996
17848382: 733 639 949 13 44
1285415254454: 377 73 415 786 82 3 2
42573460: 1 8 2 3 317 730 79 381
6487474065: 4 6 6 6 4 42 4 48 4 5 7 89
11248830: 1 570 7 7 4 3 5 7 11 6 9 6
1236900001: 24 10 720 625 57
774935037: 293 473 63 40 66
121832: 7 5 3 2 6 88 1 1 552 7 3 3
1016743: 76 37 6 658 58
2533368513: 61 4 55 636 596 21
6990058: 4 1 835 30 204
1847406607: 20 526 740 9 8
779328000: 6 373 4 2 3 8 80 9 12 5 8
96371: 3 5 88 208 156 7
5419039: 3 8 517 90 41
249830: 99 374 8 177 3 7 9 8 90
100166088: 8 9 99 5 45 733 9 264
3376144: 7 157 927 442 7 584 6
43593660: 11 9 537 99 41
411324689: 7 21 208 389 4 41 29 6
234004: 61 323 7 87 89 62
23183285: 23 18 26 6 88
97916165533: 269 91 4 165 535
1112448: 9 61 841 2 5 4 3 8 9 6 89
8963: 896 5 1
73558189852: 5 6 9 4 6 97 6 658 2 98 7
13680414: 49 47 66 90 594
24172014797: 48 336 8 5 1 479 7
9967992824: 9 41 946 706 93 28 2 4
76153297584: 47 81 66 2 975 84
541346194846: 45 1 6 73 5 2 97 4 2 2 5 2
2476666710: 2 630 15 208 17 630
60279278: 6 982 17 61 6 3 845
55027351: 4 528 9 2 88 135
929699919: 3 89 480 9 8 2 99 5 4 21
257203: 304 846 14 3 2
19954464: 4 2 199 29 8 7 2 8 6 8 12
349703121: 87 425 69 5 1 43 8 8 9
9607739480: 120 8 1 4 3 7 3 6 3 4 74 3
70229: 6 57 4 3 227
19346675608: 4 3 7 4 3 7 466 3 5 5 609
59456: 9 39 3 3 875 64
4049373107: 490 831 2 825 85 1 7
38708598: 9 8 89 40 412 1 7 18 2 5
217787072132: 186 39 5 2 3 6 9 5 355 6
1252444294: 382 309 78 42 9
7796721302: 7 796 71 6 5 300
232741316: 8 29 741 314 1
26910444: 298 907 9 879 9 15
40916974: 2 8 5 2 9 8 6 1 5 16 971
34830687: 15 387 6 668 19
49022893747: 778 140 1 17 7 4 9
240774: 4 815 4 1 5
2030: 4 95 11 46 895
141432: 8 9 395 3 5 8 7 8 3 49 7 1
466823: 1 32 544 26 71
5847912: 202 47 694 82 7
242621: 232 7 801 56 67
330876: 8 4 2 2 2 2 7 150 5 18 7
93687: 25 197 3 19 55
71444393: 1 6 5 9 7 8 5 789 8 423 9
6751035: 1 21 553 845 258 5 1
191462315465: 957 31 2 3 15 464
15511497: 55 8 2 94 73 289
494852056149: 918 7 65 77 610 4 9
116901382: 42 97 79 9 847 3 608 6
287727946: 1 643 7 8 1 2 799 5 1 7
26218340: 244 68 525 56 8 8 5 5 4
76566: 9 77 13 60 6
1830: 292 29 891 531 87
403126: 356 9 148 58 706
26406: 799 7 32 525 2 79 8
61533769122: 1 551 8 75 6 983 189
5083523328: 909 3 8 7 1 3 976 4 1 68
35952796: 7 5 952 35 39 5 51
167412767: 5 1 4 1 9 8 94 38 6 7 7 70
2195302: 85 6 308 41 46
1474198: 69 9 5 70 54
364088987: 88 8 41 8 987
78139858: 1 4 5 2 19 3 628 2 7 6 5 6
4404409: 63 832 69
78435: 7 47 2 61 5 16 7 21 5
757520426: 77 2 98 98 26
203318778: 4 281 991 7 5 62 31 8
287102009: 8 88 930 764 73 6 8 7
90227: 48 705 88 61 26
8181666: 73 8 8 166 9
4345042264: 16 1 3 8 23 5 183 8 62
1748: 74 8 5 4 2
253: 1 3 5 5 160 54
7800887: 9 4 5 7 5 99 79 15 94 7
5590: 14 42 8 5 81
37762: 87 9 48 2 9 167
333279: 2 2 58 80 363 524 1 57
171214269218: 844 322 681 3 63
118944: 5 8 7 873 93
124807260: 419 9 9 3 40 8 270 300
57067: 5 2 65 9 88 41 1
67645321537: 92 3 2 715 36 71 4 4 9 6
897: 1 7 827 62
1191701596: 94 6 393 18 83 83 3 15
1273: 3 4 7 1
144149: 5 9 32 78 68
1256472: 63 7 3 2 1 539 71 277 6
30990621: 309 83 94 668 4
38536499222: 2 510 18 1 9 95 88 780
856374: 5 802 1 492 5 7 17
130842660: 3 6 58 8 1 3 793 9 4 9
69578132: 7 21 1 5 2 47 6 99 7 1 3 3
5276748016: 8 7 53 1 208 226 93
48947804: 5 910 9 3 8 1 330 773 2
194740286300: 5 8 3 275 5 5 2 67 5 89 9
22422998: 337 7 85 37 95 905
6918244: 6 8 497 29 1
45185615913: 97 710 90 9 1 9 1 810 3
316116: 27 527 2 312 54
11292: 929 9 4 5 201 64 9 384
143302570: 4 16 808 8 117 82 888
6574936: 810 8 94 844 91
19500766: 927 48 20 7 67
5496862: 4 4 2 5 86 8 399 28 3 3 7
4081: 4 74 6 281 7
107041551: 2 57 2 900 35 9 52
365716: 8 34 43 277 3 719
233199: 34 225 11 9
75781172: 315 75 3 8 2 9 1 6 4
6441: 3 601 327 1 3 6 45
72: 7 5 6
1847: 2 645 49 191 869 90 1
689524: 27 4 504 47 44
421965206413: 87 9 6 8 4 5 206 391 25
965613600002: 4 846 6 280 7 140 690
50559280: 8 1 6 4 2 4 567 26 534 4
365496049: 9 4 32 4 8 7 6 686 7 4 2 5
64994090: 2 9 4 1 21 74 3 73 79 7
1241: 1 3 4 2 7 1 927 298
7392027906: 8 350 66 4 2 7 909
72665135998: 6 6 743 1 3 4 3 68 727 8
42527813: 6 563 5 4 3 74 13
2085967: 414 4 499 14 7
10090710861: 386 49 70 80 95 41 21
188483597: 7 582 4 8 218 54 1 877
367380998: 2 2 2 6 96 3 900 5 998
68095186: 23 615 83 8 58 665 27
6509884572: 69 3 7 3 5 447 3 29 45
24930077: 28 690 986 2 4 3 8 70
886840: 24 5 86 770 45 5 883
42180751: 55 6 7 350 535 356 90
73846429: 761 303 97 4 36
118157648: 762 70 33 91 1 9 221
31303: 316 129 114 56
2340: 1 2 1 90 13
38925682: 993 392 77 2 5
132208396: 881 37 1 90 5 8 7 3
17362906539: 165 30 832 90 653 6
513060: 806 636 6 352 86
13556739: 451 47 42 13 3
87166290: 5 85 372 295 72 4
2085930558: 856 47 3 770 559
1271377657: 9 33 460 8 7 7 8 914 6 3
92480: 40 514 24 4 40
203612568029: 9 8 9 3 4 593 8 4 4 80 3 1
997367027585: 79 95 567 99 21 6 2
14986059: 5 53 1 4 2 4 3 8 9 2 2 338
16943: 7 4 20 353
192411245217: 1 4 16 3 411 243 2 214
3267945: 932 5 35 316 8 35 993
7584118814: 7 671 470 45 7 3 34
92005506: 773 3 57 87 6 1 761 8
83148275295: 3 339 4 451 3 44 80 9 7
2758387: 393 7 7 3 88
158229124: 29 55 19 2 19 6 28 3
19731329: 2 9 1 83 7 94 6 1 2 980 9
372969: 6 731 54 84 9
44398676936: 995 485 95 8 446
29: 4 8 2 5
28812: 917 31 113 6 27
3221058: 4 4 121 4 4 5 83 41 620
5012875154: 898 6 867 8 88 75 157
619: 81 324 57 159
2000875149: 877 559 36 5 57 387 8
538511: 4 7 544 52 863
37415205: 7 45 7 9 84 9 78 4 9 991
87187684: 567 6 8 2 951 2
723726: 7 146 73 188 2 12 9 62
5611: 15 2 2 547 8
161732: 8 19 1 4 8 39 32
77322232001: 8 26 104 9 591 9 93 4 1
7664: 9 8 5 45 7 2
43978994: 462 45 951
184200: 63 29 10 5 4
24754844735: 574 385 653 66 2
38841958460: 447 488 62 14 60
512307698: 78 476 8 7 92 35 2 978
978764208: 1 83 5 78 7 56 484 4 8 4
51510: 9 1 77 9 7 32 38 7 583
519848234: 89 192 64 9 659 7 8 4 3
279759946564: 694 6 76 839 58 1 6 8 2
27642337368: 30 7 9 658 999 7 368
1714046887054: 9 4 3 88 3 699 1 7 3 976
2096866: 762 7 4 2 9 7 4 7 1 2 27 2
829347: 57 9 11 283 50 19
5188: 9 98 18 397 4
8546580: 3 931 494 63 95
2569449: 4 318 202 3 8
1008685401: 3 24 22 9 26 3 511 2 8
38907: 341 1 41 3 61 4 64
47134149: 59 5 6 423 9 55 2 6 37
156: 4 5 48 80 8
13690: 373 8 21 967 3
152680: 5 4 62 3 9 75 1 7 6 2 5 4
22638959: 203 8 12 282 4 90
667766987: 6 184 969 39 93 7 5 3 2
491050285: 9 3 9 9 9 7 6 28 270 6 8 3
123681: 9 1 5 8 4 88 91 3 4 5 14 3
2442314: 2 5 7 9 947
66996296: 6 1 9 7 48 8 1 1 8 4 4 372
527: 6 5 6 4 2
18881838: 929 53 32 45 52 21 6
41565: 44 3 73 665 8 52 2
38558: 1 5 21 68 21
6715471: 839 434 8
6389: 91 7 6 9 5 7 178 974 5 4
2117591196: 3 5 748 679 614 9 3 94
28162196: 8 7 1 32 2 196
35808181: 2 2 8 746 180
9867444479: 73 352 40 6 9 1 2 48 1 4
78674: 7 501 25 659 66
45024: 4 4 3 3 18 18 57 276 7
19756: 4 99 3 942 7
799: 34 57 708
157466: 8 2 6 8 7 678 40 9 6 69
12013722: 53 771 14 3 7
305851750: 8 736 8 8 5 6 3 34 8 7 5 1
31627: 85 8 4 85 7
120636732: 750 274 14 587 7 7
239363098: 57 7 6 69 1 1 1 8 59 5 4 6
23142: 7 7 4 3 8 579 6 6 8 8 50
330: 3 42 4 9 8 5
610059: 3 3 2 541 80 888
15743730746: 31 237 561 6 84
1289162: 5 6 57 370 11 28 8 5 2
4912012: 49 120 12
21034792439: 47 1 58 1 7 2 7 915 9 39
10550: 2 3 9 970 45 8 514 1 5
27651: 2 9 1 8 1 5 8 7 8 4 4 35
53322: 8 87 4 8 2 66 63 96 759
138446470: 26 6 47 682 4 71
1648416: 9 278 7 657 3
6538688411: 30 351 741 838 668
1344480: 7 466 85 43 7 56 424
244514648942: 468 4 7 2 5 2 1 2 37 945
241060: 8 3 5 67 8 69 6 48 4
40133289211: 659 7 87 9 7 2 9 17 4 1
435126: 783 57 518 8
17711006228220: 76 834 259 998 890
5734080: 36 1 1 288 55
8979895786: 9 2 93 110 38 8 5 21
3330: 532 23 6
10241840: 102 34 7 8 38
13305407: 2 1 4 5 8 7 259 5 2 12 5 2
1433165: 3 9 1 891 73 367 65
177433659084: 44 3 58 41 477 10 4 2
222432: 311 919 67 3 4 6 71 56
85538: 1 4 7 2 910
32399920: 9 4 9 9 9 343 93 8 3 8 70
3157308169: 1 373 938 9 169
48314570: 8 329 1 58 9 3 470 5
2157760504767: 751 9 9 76 9 2 9 7 9 2 8 3
113124347: 1 9 87 43 2 9 95 347 1
234373743: 2 9 28 89 3 4 285
65134472: 65 133 910 5 559
5111: 5 42 2 513 9 53
280608943: 45 909 7 7 7 5 5 9 4 587
4944: 40 1 9 45
177101: 80 4 186 35 2
8123256299: 643 1 251 7 58 4 9 296
2610013: 28 55 24 2 655 487 6
3473695: 10 681 6 7 17 5
102288: 44 8 693 6 8 980 4 2
792006: 80 9 71 8 1 44 73 6 82
8393424: 656 4 6 4 3 8 4 9 8 87 3 4
3357448904: 9 2 514 71 901
11955840: 5 778 1 3 2 8 3 2 4 4 16
33523655: 1 1 3 1 1 294 8 68 4 5 8 3
40658: 1 477 43 78 20
419: 5 99 4
10692: 9 8 4 4 27
2316100872: 772 5 1 6 812 6
8456347: 98 587 147 25
45388: 6 755 4 4 18 59
98449258: 90 859 57 260 7
290537744: 880 4 3 514 8 11
1920630535: 5 7 1 57 4 6 4 84 1 771
41738341141: 8 3 103 9 3 4 6 5 962
267888: 53 5 71 5 36
457162268328: 14 3 754 7 71 9 6 318
9818370: 378 26 9 30 10 3 90
136158886: 8 1 7 95 325 2 1 5 3 8 7
407: 6 42 69 8 78
1012705468: 822 4 44 7 657 811
4180406340096: 466 981 98 12 6 36 9 4
10705064: 4 424 136 5 931 181
2217819683: 7 51 62 9 9 423 96 3 5 4
7508279323: 3 250 555 272 3 6 32 2
2658216: 558 18 25 4 66
59297: 60 97 2 747 351
7495229447: 8 328 9 266 28 50
2644059830523: 57 55 2 97 574 815 8
54008124608: 94 751 10 958 57
2207268: 50 592 72 49 50 7 9
9395936945: 83 33 540 34 9 806 4
65754981: 340 41 89 53
5424: 267 8 2 69
194627: 564 43 8 613 1
75167376: 75 166 1 972 404
237336645000: 628 915 45 700 590
522553: 7 58 4 91 7 2 7 9 148 49
4897: 29 13 6 95
13670996090: 500 614 6 73 31 610
16290039939: 74 7 6 1 7 882 87 2 438
2804002896239: 85 2 41 17 5 52 774 5
86506: 910 1 29 157 73 74
21660911180: 722 2 15 911 180
6815: 6 743 72
114802992537: 6 17 215 5 39 1 5 186 2
720907: 203 61 587 39 81 8
15904808: 28 3 80 96 5 5
200829237621: 999 710 37 3 744 27
95188135587: 835 3 68 49 755 579 8
61525: 81 49 4 75 3 4 5 8 28
13221210319: 3 486 9 6 6 4 20 5 5 6 2 8
3728996709124: 945 71 9 708 62 96 6 1
39283710: 7 46 6 3 64 51 9 717
24046652: 1 8 92 61 34 2 646 46 7
178492223: 4 1 18 61 81 5 7 2 8 194
1677144138: 6 123 83 227 39
105579656: 2 3 4 7 2 96 8 6 63 6 366
78276190303: 7 94 9 131 13 41 3 7 9
110367683: 778 9 8 5 5 3 4 9 394 9
7626312605: 4 502 5 552 1 72 598 5
56319236258: 9 5 39 82 6 8 9 548 258
5406139: 642 842 45 4 6
45342: 7 29 96 267 8 1 2 50
7525096: 1 820 330 35 97
80899207: 11 236 80 9 7
1022048029: 328 76 82 5 24 7
853304431680: 313 630 752 6 603
4608388638: 31 9 958 177 93
68959734: 7 8 33 5 44 732 6 2 6 4
4653: 845 319 4
2523796352: 2 51 789 2 4 8 98
185856: 885 21 6
19948509: 72 83 24 3 910 396
1680716: 236 37 35 71 3
+50
View File
@@ -0,0 +1,50 @@
...d............................J.................
......e.............................J.............
..........6............7..........................
........................P7........................
..................................................
.........6........................................
e..........................x.................E....
...G...A.......d...........................o......
.....A.e...........................J......8.......
................6....9.....J.............E.8......
..........d.9.........7..K....E...................
...e.....U....9................x..K...............
......A......O...........P................o.......
......................x..................M..E.....
........................x........p................
........A..................O......................
.......r.f....O.......P9..G.........m.............
u...df..r...............7.........................
.....g.............nXu......N.........K...........
..............l..........0..............p.........
.......lu...................p......o..............
....g..........l........0p..G.....F...............
.....................................8......F.....
...................................C..............
....3................G0......................M....
2...f....g..........3........P......O......F......
g......3.....0....H......................F..M.....
.............c................m...h.....M.........
...........2....l.................................
..U...c......2...........................K........
.D....................r.....f.....................
....................N.............................
.U..............h.................................
...a.............u..............C.................
c...Uj....a..6...H...................R............
...3....j................H...............m........
.......................5.......C..........4....m..
......................H.........R......N....X.....
.........h..2.................R................N..
.......................r...........q...n..........
.....c..............5.............................
..a..h....D.................................n.....
......qk..................D............1.....X....
.k..................................q.............
..k..........a.............L................1....4
......k..........RQ..5.L.j..1..................4..
..................................................
..............L.....................oX............
........Q.............L.........n.................
...........Q.D........5..........1............4...
+1
View File
@@ -0,0 +1 @@
2333133121414131402
+12
View File
@@ -0,0 +1,12 @@
##....#....#
.#.#....0...
..#.#0....#.
..##...0....
....0....#..
.#...#A....#
...#..#.....
#....#.#....
..#.....A...
....#....A..
.#........#.
...#......##
+50
View File
@@ -0,0 +1,50 @@
...d......###......#.##........#J.#.#.#....#.....#
..#..#e#..#........###.#.#...#....##J............#
#.....#.#.6##..###.#.#.7............##..#..##.....
#.#...#...#....##..##...P7#......#..##...##.#....#
###.#.....#####....##......#..##..#.#.#........###
..#...##.6##.#....#..........#..#..##.##..#..#...#
e.#.##..##...#..#..#..#....x...#..#.#...###..E..##
...G..#A#.#..##d#..........##..#.#.#..##.#.o.#...#
....#A.e##..#..#............#.##...J..#..#8.#....#
#..##.#####.#.#.6.#..9....#J.####..#.#..#E.8......
.#........d.9.#.#..##.7..K....E..##....#....#...#.
.##e...##U###.9#..###...#...##.x..K......#...##...
...#..A##....O..##..##...P....#...#..#.#.#o#..#..#
....##.#...#.##.#.#..#x#....#.....#...##.M..E#.#.#
....####......##.#..##..x..##....p...##.##....####
#.....#.A...#####.....#...#O##...##..##...##.....#
#.....#r#f....O.......P9#.G##.....##m.#.#.....#..#
u#..df#.r..#.##..###....7##.#.#......#..##.....##.
##..#g.#.##..#.#...nXu#...##N#..#.##.#K..##....###
..........#...l...##.....0....##..#.....p##..#...#
....##.lu.##..####.#....#.#.p.#.##.o#...#..#...#.#
#...g....#..#.#l#....#..0p#.G..##.F.####.....##...
.#..#....#.#.#..#....###.......#.##.#8..##..F.#..#
.#.##....##...#.#..#...###.###.#...C..#...##..##..
#..#3..#.#..#####.#..G0...#...#.##.#...###..#M.#..
2###f#...g...#..##..3.#......P......O...#.#F#.####
g.##...3..#.#0...#H.#..###....#.....#....F.#M..##.
..##...#.#..#c#.###.##...#...#m.#.h..#.#M.#...#...
....#..#..#2.#..l#.#........##.....###....##.#.##.
.#U..#c.#.#..2#..#.###..........#.##.....K....###.
.D.....#.#.#.#.#..#..#r.#..#f....###.##...#.#.#...
..#.......#.##.#.###N.###...#..###.......####..##.
#U#.......##.##.h####..#.##..#..#.....#.#####.#...
###a...#.##..#..#u####..#.#####.C......##.........
c...Uj.#..a.#6.##H.#...#.#.#.....#.##R#.##........
#..3....j#...#...#.#..##.H#..#.#..#.#..#.m...#..##
....##.#.#.##.#..###.##5####...C###..#.#..4#...m#.
##............#.#.##..H##...##.#R.#..#.N##..X....#
.........h#.2#.#.#......##...#R###....#........N.#
.#....#.#..###.#.#.##..r##..#.#..#.q..#n.....#.#..
....#c.....###.....#5..#..###..##.##.##....##..#..
..a..h....D#.##.#...##.####..#..#...##.###..n...#.
##....qk.##....##.#...###.D.##.#.#.##..1.....X....
.k.....#....##......#.#...#..####.#.q#...###.....#
.#k..#..#.#.#a#..###.#.....L...##.##.#.....#1.##.4
...#..k##.#.#...#RQ..5#L.j.#1...#.#.#.#......#.4..
.##.#.#...#.#.#.##.####.#.#.......#.###..#...#.#.#
.....#.#...##.L#........#.#.#.....##oX#....##.#.##
.....##.Q.##.###.##...L.####.##.n#.....###.....#..
.#..##.##.#Q#D..#.##..5....#.##..1##...##.#...4...
+17
View File
@@ -0,0 +1,17 @@
"""Advent of Code 2025 utilities."""
from .helpers import (
read_input,
read_lines,
read_ints,
read_grid,
read_blocks,
)
__all__ = [
"read_input",
"read_lines",
"read_ints",
"read_grid",
"read_blocks",
]
+52
View File
@@ -0,0 +1,52 @@
"""Input parsing and common utilities for Advent of Code."""
from pathlib import Path
from typing import Callable, Any
import numpy as np
def get_input_path(day: int) -> Path:
"""Get the path to input file for a given day."""
return Path(__file__).parent.parent / "inputs" / f"day{day:02d}.txt"
def read_input(day: int) -> str:
"""Read raw input for a given day."""
return get_input_path(day).read_text().strip()
def read_lines_and_split(day: int, split: str) -> list:
"""Read input as lines, optionally parsing each line."""
return [line for line in read_input(day).split(split)]
def read_lines(day: int, parser: Callable[[str], Any] = str) -> list:
"""Read input as lines, optionally parsing each line."""
return [parser(line) for line in read_input(day).splitlines()]
def read_ints(day: int) -> list[int]:
"""Read input as list of integers (one per line)."""
return read_lines(day, int)
def read_grid(day: int, dtype=str) -> np.ndarray:
"""Read input as a 2D numpy grid of characters or digits."""
lines = read_input(day).splitlines()
if dtype == int:
return np.array([[int(c) for c in line] for line in lines])
return np.array([list(line) for line in lines])
def read_blocks(day: int) -> list[str]:
"""Read input split by blank lines (paragraphs)."""
return read_input(day).split("\n\n")
# Common grid directions
DIRS_4 = [(0, 1), (1, 0), (0, -1), (-1, 0)] # right, down, left, up
DIRS_8 = DIRS_4 + [(1, 1), (1, -1), (-1, 1), (-1, -1)] # + diagonals
# Direction mappings
DIR_MAP = {
"R": (0, 1), "L": (0, -1), "U": (-1, 0), "D": (1, 0),
">": (0, 1), "<": (0, -1), "^": (-1, 0), "v": (1, 0),
}
+62
View File
@@ -0,0 +1,62 @@
"""Day 1: Advent of Code 2025."""
from aoc import read_lines, read_input
def get_pointer(dial, move, pointer):
dir = move[0]
n = int(move[1:])
if dir == 'L':
pointer = (pointer - n) % len(dial)
elif dir == 'R':
pointer = (pointer + n) % len(dial)
return dial[pointer]
def part1(data):
dial = range(100)
password = 0
pointer = 50
for line in data:
move = line.strip()
pointer = get_pointer(dial, move, pointer)
if pointer == 0:
password += 1
return password
def get_new_index(dial, move, pointer):
dir = move[0]
n = int(move[1:])
if dir == 'L':
pointer = (pointer - n)
elif dir == 'R':
pointer = (pointer + n)
return pointer
def part2(data):
dial = range(100)
password = 0
pointer = 50
for line in data:
move = line.strip()
if len(move[1:]) > 2:
n = int(move[1:][:-2])
move = move[0] + move[-2:]
password += n
idx = get_new_index(dial, move, pointer)
if pointer != 0 and (idx < 0 or idx > len(dial)):
password += 1
pointer = idx % len(dial)
if pointer == 0:
password += 1
return password
if __name__ == "__main__":
data = read_lines(1) # or read_input(1), read_ints(1), read_grid(1)
print(f"Part 1: {part1(data)}")
print(f"Part 2: {part2(data)}")
+52
View File
@@ -0,0 +1,52 @@
from aoc import read_lines, read_input
from aoc.helpers import read_lines_and_split
def part1(data):
ids = []
for line in data:
n = line.strip().split("-")
r = range(int(n[0]), int(n[1]) + 1)
for rr in r:
ss = str(rr)
if (len(ss) % 2) == 0:
f = ss[:len(ss)//2]
s = ss[len(ss)//2:]
if f == s:
ids.append(rr)
return sum(ids)
def find_pattern(s):
if len(s) < 2:
return False
n = int(s)
if all_same(n):
print(f"Found pattern: {n}")
return True
for i in range(2, len(s) // 2 + 1):
pattern = s[:i]
repeated = pattern * (len(s) // i)
if str(repeated) == s:
print(f"Found pattern: {pattern} in {s}")
return True
return False
def all_same(n):
return len(set(str(n))) == 1
def part2(data):
ids = []
for line in data:
n = line.strip().split("-")
r = range(int(n[0]), int(n[1]) + 1)
for rr in r:
ss = str(rr)
if find_pattern(ss):
ids.append(rr)
return sum(ids)
if __name__ == "__main__":
data = read_lines_and_split(2, ",") # or read_input(2), read_ints(2), read_grid(2)
print(f"Part 1: {part1(data)}")
print(f"Part 2: {part2(data)}")
File diff suppressed because it is too large Load Diff
+1
View File
@@ -0,0 +1 @@
52500467-52574194,655624494-655688785,551225-576932,8418349387-8418411293,678-1464,33-79,74691-118637,8787869169-8787890635,9898977468-9899009083,548472423-548598890,337245835-337375280,482823-543075,926266-991539,1642682920-1642753675,3834997-3940764,1519-2653,39697698-39890329,3-21,3251796-3429874,3467-9298,26220798-26290827,80-124,200638-280634,666386-710754,21329-64315,250-528,9202893-9264498,819775-903385,292490-356024,22-32,2663033-2791382,133-239,56514707-56704320,432810-458773,4949427889-4949576808
+10
View File
@@ -0,0 +1,10 @@
[project]
name = "aoc2025"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = [
"numpy",
]
[tool.uv]
dev-dependencies = []
+9
View File
@@ -0,0 +1,9 @@
# Advent of Code
My solutions to [Advent of Code](https://adventofcode.com/) puzzles.
## Years
- [2023](./2023)
- [2024](./2024)
- [2025](./2025)