Compare commits

...

15 Commits

Author SHA1 Message Date
Bram 65efdbd0bd Add benchmarks for Bob, Bram, Brechtje & Vicky on day 2 2025-12-03 19:58:29 +01:00
Bram af6536cd94 Merge Brechtje's branch into benchmark branch 2025-12-03 18:21:03 +01:00
Bram 9eff6e92d4 Merge Vicky's branch into benchmark branch 2025-12-03 18:20:16 +01:00
Bram 08f116ec57 Merge Bob's branch into benchmark branch 2025-12-03 18:19:26 +01:00
Bram 85972ec4bf Merge Bram's branch into benchmark branch 2025-12-03 18:18:35 +01:00
Vicky cb21b0e323 Upload dec2 code. 2025-12-03 07:04:05 +00:00
Vicky b42c2a8852 Add executable file. 2025-12-03 06:51:45 +00:00
Vicky 0f45ec9393 Upload dec1 code
Part 1 only!
2025-12-03 06:46:38 +00:00
Brechtje van Gessel a92e05928f first attempt at day 2 part 2 2025-12-02 21:01:09 +01:00
Brechtje van Gessel 5a814f6c47 day 2 part 1 solved! 2025-12-02 18:44:07 +01:00
Bram d01764721a Optimize & simplify day 1 2025-12-02 16:31:07 +01:00
Bob 8a21b6b78a day02 2025-12-02 13:17:40 +01:00
Bram a278f98f4b Add day 2 (rough version) 2025-12-02 09:20:53 +01:00
Bram 64ba806ee0 Prepare day 2 2025-12-01 11:43:13 +01:00
Vicky dd73313655 Add vicky/README.md 2025-11-26 08:49:40 +00:00
43 changed files with 11664 additions and 170 deletions

41
bob/day02/day02-p1.py Normal file
View File

@ -0,0 +1,41 @@
def check_id(start, end):
false_ids = []
for id in range(int(start), int(end)+1):
id_str = str(id)
id_str_len = len(id_str)
if id_str_len % 2 == 0:
h1 = id_str[:id_str_len//2]
h2 = id_str[id_str_len//2:]
if h1 == h2:
false_ids.append(id)
return false_ids
def read_input(filename):
id_ranges = []
for line in open(filename).read().splitlines():
for id_range in line.split(","):
start = id_range.split("-")[0]
end = id_range.split("-")[1]
id_ranges.append((start,end))
return id_ranges
# filename = "day02/example_input" # 1227775554
filename = "day02/input" # 23560874270
id_ranges = read_input(filename)
adding = 0
for id_range in id_ranges:
for false_id in check_id(id_range[0], id_range[1]):
adding += false_id
print(f"Added total of false IDs: {adding}")

61
bob/day02/day02-p2.py Normal file
View File

@ -0,0 +1,61 @@
def check_id(start_id, end_id):
false_ids = []
for id in range(int(start_id), int(end_id)+1):
id_str = str(id)
id_str_len = len(id_str)
for substr_len in range(1,(id_str_len//2)+1):
if id_str_len % substr_len > 0:
# Substring being checked must fit a whole number of times
continue
dup = False
# Substring position is determined by the amount of times the substring fits in the string
# That makes up the range to be checked (as multipliet with the substring length)
for substr_pos in range(1, id_str_len // substr_len):
h1 = id_str[:substr_len]
# Get the substring at right position, and only with size of substring
h2 = id_str[substr_len*substr_pos:][:substr_len]
if h1 != h2:
dup = False
break
else:
dup = True
if dup:
false_ids.append(id)
break
return false_ids
def read_input(filename):
id_ranges = []
for line in open(filename).read().splitlines():
for id_range in line.split(","):
start = id_range.split("-")[0]
end = id_range.split("-")[1]
id_ranges.append((start,end))
return id_ranges
# filename = "day02/my_example_input" #
# filename = "day02/example_input" # 4174379265
filename = "day02/input" # 44143124633
id_ranges = read_input(filename)
adding = 0
for id_range in id_ranges:
for false_id in check_id(id_range[0], id_range[1]):
adding += false_id
print(f"Added total of false IDs: {adding}")

1
bob/day02/example_input Normal file
View File

@ -0,0 +1 @@
11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,446443-446449,38593856-38593862,565653-565659,824824821-824824827,2121212118-2121212124

1
bob/day02/input Normal file
View File

@ -0,0 +1 @@
990244-1009337,5518069-5608946,34273134-34397466,3636295061-3636388848,8613701-8663602,573252-688417,472288-533253,960590-988421,7373678538-7373794411,178-266,63577667-63679502,70-132,487-1146,666631751-666711926,5896-10827,30288-52204,21847924-21889141,69684057-69706531,97142181-97271487,538561-555085,286637-467444,93452333-93519874,69247-119122,8955190262-8955353747,883317-948391,8282803943-8282844514,214125-236989,2518-4693,586540593-586645823,137643-211684,33-47,16210-28409,748488-837584,1381-2281,1-19

View File

@ -0,0 +1 @@
12345678-12345679

File diff suppressed because one or more lines are too long

View File

@ -37,3 +37,9 @@ Sander uses [GHCup](https://www.haskell.org/ghcup/) at version 9.6.7. Haskell
typically opens as a REPL from which functions can be evaluated, so some typically opens as a REPL from which functions can be evaluated, so some
liberties are taken here. The script is reformatted in the `sander_hs/` folder liberties are taken here. The script is reformatted in the `sander_hs/` folder
and compiled to a binary in order to approximate performance. and compiled to a binary in order to approximate performance.
Vicky uses [Jupyter Notebook](https://jupyter.org/). A Notebook is difficult
to benchmark and the `*.py` exported files cannot compute properly due to
wrong ordering of function definitions and scripts. The exported script is
reformatted in the `vicky_py/` folder and run as an ordinary Python script
in order to approximate performance.

View File

@ -6,4 +6,10 @@ hyperfine --warmup 5 --export-json ../bram/benchmarks/data/bob-d01-p1.json \
hyperfine --warmup 5 --export-json ../bram/benchmarks/data/bob-d01-p2.json \ hyperfine --warmup 5 --export-json ../bram/benchmarks/data/bob-d01-p2.json \
--runs 100 "python day01/day01-p2.py" --runs 100 "python day01/day01-p2.py"
# Benchmark day 2
hyperfine --warmup 5 --export-json ../bram/benchmarks/data/bob-d02-p1.json \
--runs 100 "python day02/day02-p1.py"
hyperfine --warmup 5 --export-json ../bram/benchmarks/data/bob-d02-p2.json \
--runs 100 "python day02/day02-p2.py"
cd ../bram/benchmarks cd ../bram/benchmarks

View File

@ -8,4 +8,8 @@ cargo build --release
hyperfine --warmup 5 --export-json ../benchmarks/data/bram-d01-100.json \ hyperfine --warmup 5 --export-json ../benchmarks/data/bram-d01-100.json \
--runs 100 "for run in {1..100}; do target/release/aoc2025 1; done" --runs 100 "for run in {1..100}; do target/release/aoc2025 1; done"
# Benchmark day 2
hyperfine --warmup 5 --export-json ../benchmarks/data/bram-d02.json \
--runs 100 "target/release/aoc2025 2"
cd ../benchmarks cd ../benchmarks

View File

@ -10,4 +10,14 @@ hyperfine --warmup 5 \
--runs 100 "python 1-2.py" --runs 100 "python 1-2.py"
cd ../ cd ../
# Benchmark day 2
cd 2/
hyperfine --warmup 5 \
--export-json ../../bram/benchmarks/data/brechtje-d02-p1.json \
--runs 100 "python 2-1.py"
# hyperfine --warmup 5 \
# --export-json ../../bram/benchmarks/data/brechtje-d02-p2.json \
# --runs 100 "python 2-2.py"
cd ../
cd ../bram/benchmarks cd ../bram/benchmarks

View File

@ -17,6 +17,24 @@
], ],
"runs": 1 "runs": 1
}, },
{
"name": "bob-d02-p1.json",
"author": "Bob",
"lang": "Python",
"puzzles": [
"2-1"
],
"runs": 1
},
{
"name": "bob-d02-p2.json",
"author": "Bob",
"lang": "Python",
"puzzles": [
"2-2"
],
"runs": 1
},
{ {
"name": "bram-d01-100.json", "name": "bram-d01-100.json",
"author": "Bram", "author": "Bram",
@ -27,6 +45,16 @@
], ],
"runs": 100 "runs": 100
}, },
{
"name": "bram-d02.json",
"author": "Bram",
"lang": "Rust",
"puzzles": [
"2-1",
"2-2"
],
"runs": 1
},
{ {
"name": "brechtje-d01-p1.json", "name": "brechtje-d01-p1.json",
"author": "Brechtje", "author": "Brechtje",
@ -45,6 +73,15 @@
], ],
"runs": 1 "runs": 1
}, },
{
"name": "brechtje-d02-p1.json",
"author": "Brechtje",
"lang": "Python",
"puzzles": [
"2-1"
],
"runs": 1
},
{ {
"name": "sander-d01-p1.json", "name": "sander-d01-p1.json",
"author": "Sander", "author": "Sander",
@ -53,5 +90,32 @@
"1-1" "1-1"
], ],
"runs": 1 "runs": 1
},
{
"name": "vicky-d01-p1.json",
"author": "Vicky",
"lang": "Python",
"puzzles": [
"1-1"
],
"runs": 1
},
{
"name": "vicky-d02-p1.json",
"author": "Vicky",
"lang": "Python",
"puzzles": [
"2-1"
],
"runs": 1
},
{
"name": "vicky-d02-p2.json",
"author": "Vicky",
"lang": "Python",
"puzzles": [
"2-2"
],
"runs": 1
} }
] ]

View File

@ -0,0 +1,218 @@
{
"results": [
{
"command": "python day02/day02-p1.py",
"mean": 0.6765645741299999,
"stddev": 0.013047081521433405,
"median": 0.6763296411999999,
"user": 0.6704550699999997,
"system": 0.0033457500000000006,
"min": 0.6559922267,
"max": 0.7329195817,
"times": [
0.6721216407,
0.6837450707,
0.6612521137,
0.7061815837000001,
0.6782755407,
0.6756507177,
0.6763355687,
0.6747942667,
0.6742392807,
0.6697994717,
0.6772529837,
0.6791377247,
0.6907288917,
0.6806539377,
0.6746299437,
0.6630597017,
0.6833341667,
0.6586809947,
0.6780386567,
0.6665040597,
0.6790600897,
0.6725939877,
0.6836183607,
0.6667784267,
0.6881150217,
0.6633574487,
0.6789564937,
0.6613500027,
0.6788042957,
0.6559922267,
0.6847969757,
0.6627792757,
0.6782401647,
0.6743326107000001,
0.6649894047,
0.6789302837,
0.6733824407,
0.6910859527,
0.6631805447,
0.6774636637,
0.6636205517,
0.6766484967,
0.6645901637,
0.6870083157,
0.6716324417,
0.6737801617,
0.6596793037,
0.6751984447,
0.6685770937,
0.7028166087,
0.6623790377,
0.7329195817,
0.6604573647,
0.6654454177,
0.6786648997,
0.6839100787,
0.6742385397,
0.6809124307,
0.6721741527,
0.6876361547000001,
0.6739140267,
0.6897047877,
0.6610092357,
0.6812850487,
0.6618630357,
0.6984109777,
0.6843995077,
0.6831293417000001,
0.6755151757,
0.6954556917,
0.6838049437,
0.6854161367,
0.6644793797,
0.6815224767,
0.6598976727,
0.6771346357,
0.6650421847,
0.6763237137,
0.6841810567,
0.6584676787,
0.6775632687,
0.6646109447,
0.6766417327,
0.6934756047,
0.6619941597,
0.7224684777,
0.6683667787,
0.6757852777,
0.6846177207,
0.6634212887000001,
0.6667221867,
0.6629606137,
0.6946760817000001,
0.6825597837,
0.6883855197000001,
0.6802924857,
0.6920363677,
0.6617500997,
0.6885187957,
0.6641402897
],
"exit_codes": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
}
]
}

View File

@ -0,0 +1,218 @@
{
"results": [
{
"command": "python day02/day02-p2.py",
"mean": 3.1411235393800023,
"stddev": 0.09010917592789626,
"median": 3.1516303696400003,
"user": 3.12365489,
"system": 0.0037003824,
"min": 2.9177929816400003,
"max": 3.3309852776400004,
"times": [
2.9652076266400003,
2.94590746764,
2.98981463564,
2.9729601746400003,
3.00578729364,
2.99013505564,
2.95797140864,
2.9177929816400003,
3.01275715464,
2.96446652464,
2.9992746066400002,
3.0681215826400003,
2.9994085316400003,
3.05605645264,
3.0923019056400003,
2.9927535396400002,
3.16385909764,
3.05204224764,
3.0858553146400003,
3.13455088764,
3.00870479064,
3.15192396764,
3.13008368764,
3.02525549964,
3.1751920726400003,
3.05271520864,
3.1651680526400003,
3.08022751464,
3.06994534964,
3.1041971736400003,
3.09049831064,
3.11271712564,
3.14065801364,
3.17754279864,
3.1740638966400003,
3.11830439464,
3.1824652826400004,
3.20768418464,
3.18065167664,
3.14985830764,
3.19244600764,
3.12618327164,
3.15278101564,
3.13079327164,
3.21233919964,
3.22450479464,
3.22261788564,
3.1617373696400004,
3.15098288864,
3.2985043156400002,
3.16874892464,
3.2594790126400004,
3.2451113896400003,
3.1363089956400003,
3.22750851964,
3.1238160186400004,
3.21266349964,
3.19715920764,
3.1400409646400003,
3.22091029564,
3.0808952896400004,
3.17721545864,
3.16580803764,
3.17711754864,
3.22028719564,
3.07481461464,
3.19479676664,
3.06944805064,
3.20435482264,
3.25197998764,
3.1704874646400003,
3.0864505126400004,
3.16557759864,
3.0916870816400004,
3.1974675986400003,
3.10256814464,
3.1972331736400004,
3.10812775564,
3.2413019226400004,
3.1177898556400003,
3.2214804696400003,
3.2363775076400003,
3.18994465864,
3.3309852776400004,
3.10970241464,
3.21878945164,
3.27304197564,
3.12559536564,
3.20429148464,
3.2695753186400003,
3.1288451576400003,
3.1550812336400003,
3.2790448636400003,
3.25666697264,
3.2653465116400002,
3.2582973886400004,
3.15133677164,
3.30450361964,
3.2227860506400003,
3.14573391564
],
"exit_codes": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
}
]
}

View File

@ -2,114 +2,114 @@
"results": [ "results": [
{ {
"command": "for run in {1..100}; do target/release/aoc2025 1; done", "command": "for run in {1..100}; do target/release/aoc2025 1; done",
"mean": 0.10949902425999998, "mean": 0.21164170808000005,
"stddev": 0.01303120138107424, "stddev": 0.056955047683642006,
"median": 0.10794122648000001, "median": 0.24140312996000002,
"user": 0.0481385, "user": 0.08617460999999998,
"system": 0.06004530999999999, "system": 0.12323376000000001,
"min": 0.08743557148000002, "min": 0.09427125596000001,
"max": 0.14346140548, "max": 0.29016765496,
"times": [ "times": [
0.10262904248000002, 0.09427125596000001,
0.10309315948000002, 0.12272227296000002,
0.08788191948000001, 0.10814566496000001,
0.08788880848000001, 0.10705469596000002,
0.08988906048000002, 0.10612934196000001,
0.08751818448000001, 0.10502282896000001,
0.08957111248, 0.11451358096000001,
0.09758415848000002, 0.13781039596000003,
0.09701446348000001, 0.14639948396000002,
0.09691613148000001, 0.14775158996,
0.09622675148000001, 0.14817557096,
0.09456499148000001, 0.14604463696000003,
0.09579022648000002, 0.14846508596000002,
0.09444151848000001, 0.15151252196,
0.09508792248000002, 0.16783332096,
0.09606605248000001, 0.16853679196000002,
0.09695228048000001, 0.16997342296,
0.09945660648000001, 0.16844706396,
0.09628507748000001, 0.16908728596000003,
0.09672642548000002, 0.16891443496000003,
0.09634512948000001, 0.16828961096000003,
0.09588621348000001, 0.16992359796,
0.09470692948000001, 0.17080439496000002,
0.09532162748000002, 0.19855591796000002,
0.09455080948000001, 0.20074445296,
0.09497292148000001, 0.21440801796000003,
0.10120339848000001, 0.24350181396000004,
0.11154805048000001, 0.24561736796000003,
0.11532427548000002, 0.24196612596000003,
0.12480157548000002, 0.24360409496000002,
0.12592739948, 0.24331767996000003,
0.12507496648, 0.24652441296000002,
0.12549518748, 0.24279184496000003,
0.12522092848, 0.24485893696000002,
0.12732470448, 0.24116745896000003,
0.12790656448, 0.24598800796000003,
0.12489098348000001, 0.24296923896000003,
0.13339627348, 0.24656006396000002,
0.10624044648000001, 0.24561899196000003,
0.10724894148000001, 0.24682820696000002,
0.10669420748000001, 0.24173350996,
0.10763329948000001, 0.24652734996000003,
0.10534154348000001, 0.24163880096,
0.10543322348000002, 0.24588214996000002,
0.10665542748000001, 0.24245050996000003,
0.10487852848000001, 0.24488809296000003,
0.10716879648000001, 0.24555391596000004,
0.11600640648000002, 0.24579904396000002,
0.11622806648000002, 0.24346369196000003,
0.11648707548000001, 0.24628135196000003,
0.11719899848000001, 0.24546565196000003,
0.11843976248000002, 0.24388913296000003,
0.08857608548000001, 0.24583599996000002,
0.09061829048000002, 0.24499407696000003,
0.08743557148000002, 0.24350880296000002,
0.10892493048000002, 0.24843729096000003,
0.11079558148000002, 0.24303126896000002,
0.11606146848000001, 0.20900605496000002,
0.12125704848000002, 0.11419109996000001,
0.12159368348000002, 0.11346394096000001,
0.11949176648000001, 0.13605218496000002,
0.11928547748000001, 0.14135073496000003,
0.12190114648000001, 0.14054553696000002,
0.12102119648000001, 0.14170314596000003,
0.12058027548000001, 0.14030605696,
0.12061425148000002, 0.14126451896000003,
0.12009168948000001, 0.16392311396,
0.12136069848000001, 0.18885592696000003,
0.12952496048, 0.18878119396,
0.09928884548000001, 0.18838356896000003,
0.09773379248000001, 0.18918338996000003,
0.09590983548000001, 0.18812068296,
0.10297853048000001, 0.19095238196000003,
0.11318080748000002, 0.19126939996000003,
0.11342295148000002, 0.18889649096000002,
0.11455993448000001, 0.18961129496,
0.11295701548000002, 0.18977580196000002,
0.11299484748000001, 0.18796707096,
0.11239145748000001, 0.22432580396000001,
0.11219660648000002, 0.22725841896,
0.11406977448000001, 0.24249487096000003,
0.11238566648000001, 0.28284325996,
0.11289772048000002, 0.28933039296,
0.11166642748000001, 0.28381035196,
0.12329825748000002, 0.28812964996,
0.12529479848, 0.28587865196,
0.13912101548, 0.28771304996,
0.14346140548, 0.28530770596,
0.14263528748, 0.28554755196,
0.12373552048000001, 0.28769848096,
0.10561196548000001, 0.28434687996,
0.10513752748, 0.28651199196,
0.10701318248000001, 0.28607062296,
0.10513885148000002, 0.28923057896,
0.10542516148000002, 0.28878584896,
0.10548880248000002, 0.28557950296,
0.10595660348000001, 0.29016765496,
0.10824915348000001, 0.28701344896,
0.11516850448000002, 0.28762125696,
0.12826149748000001 0.28466910996
], ],
"exit_codes": [ "exit_codes": [
0, 0,

View File

@ -0,0 +1,218 @@
{
"results": [
{
"command": "target/release/aoc2025 2",
"mean": 0.95519874726,
"stddev": 0.044124744291853195,
"median": 0.9539973693000001,
"user": 0.9509290699999997,
"system": 0.0004994800000000004,
"min": 0.9081787933000001,
"max": 1.3391311813,
"times": [
0.9081787933000001,
0.9308759813000002,
0.9142113613000001,
0.9193022683000001,
0.9168911283000001,
0.9253488913000001,
0.9312279043000001,
0.9356256283000001,
0.9492816713000001,
0.9366174083000001,
0.9250868713000001,
0.9360851383000001,
0.9296086603000001,
0.9412757703000001,
0.9305709973000001,
0.9433563383000001,
0.9328483643000001,
0.9234778363000001,
0.9411994823000001,
0.9501147403000001,
0.9559593323000001,
0.9364716953000001,
0.9493212363000001,
0.9406622733000001,
0.9539723113000002,
0.9497769683000001,
0.9555531353000001,
0.9487832943000001,
0.9615137793000001,
0.9561215063000001,
0.9718753403000001,
0.9563764693000001,
0.9643665283000001,
0.9637328313000001,
0.9707989003000002,
0.9186347943000001,
0.9741552383000001,
0.9165410013000002,
0.9262016423000001,
0.9540224273000001,
0.9277363903000001,
0.9548339213000001,
0.9273572813000001,
0.9300478423000001,
0.9528168093000001,
0.9275888603000001,
0.9552747403000001,
0.9330515603000001,
0.9566409853000001,
0.9312747113000001,
0.9553285483000001,
0.9258871153000001,
0.9735189993000001,
0.9729769113000001,
0.9651232503000001,
0.9375781063000002,
0.9767990263000002,
0.9542527273000001,
0.9342905783000001,
0.9631512283000001,
0.9617953713000001,
0.9813052893000002,
0.9570536853000001,
0.9289222813000001,
0.9927794953000001,
0.9329621083000001,
1.3391311813,
0.9325888323000001,
0.9621946303000001,
0.9333018313000001,
0.9646547103,
0.9413923583000001,
0.9640935883000001,
0.9897789913000001,
0.9324330013000001,
0.9643400343000001,
0.9848533673000001,
0.9647858223000001,
0.9767217923000001,
0.9635894333000001,
0.9659293263000001,
0.9638130933000001,
0.9872895043000001,
0.9596654163000001,
0.9833496003000001,
0.9814118083000001,
0.9748250483,
0.9946907663000001,
0.9336311843000001,
0.9904872243000001,
0.9579200363000001,
0.9371263093000001,
0.9715577773000001,
0.9408078893000001,
1.0061055943000001,
0.9466207803000001,
0.9793392493000002,
0.9678916383000001,
0.9669369003000001,
0.9402422413000001
],
"exit_codes": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
}
]
}

View File

@ -0,0 +1,218 @@
{
"results": [
{
"command": "python 2-1.py",
"mean": 1.5766493539500004,
"stddev": 0.0455222865695424,
"median": 1.5766019187999998,
"user": 1.5664454400000007,
"system": 0.00335977,
"min": 1.4803841823,
"max": 1.6721914603,
"times": [
1.5272328693000001,
1.4921730793,
1.5905018103,
1.4803841823,
1.5308374893,
1.5602105813,
1.5190082873,
1.5376498373,
1.5758360573,
1.4973574432999999,
1.5077385823,
1.5211455033,
1.5376435323,
1.4908944122999999,
1.5514813263,
1.5867757103,
1.5959099863000001,
1.6113877113,
1.5681910803,
1.6264837603,
1.5657511333,
1.5962727323,
1.5743556022999998,
1.4852742363,
1.5863668273,
1.5993799273,
1.6150561123,
1.5037628413,
1.6125845143,
1.5888177133,
1.5342755693,
1.5932445243,
1.5069206643,
1.5635267083,
1.5118950973,
1.5228677273,
1.5397949743,
1.5938155213,
1.5315042873,
1.5977120243,
1.6180576373,
1.5185230233,
1.6455592843,
1.5585295342999999,
1.5982096653,
1.5727382893000001,
1.6029695213,
1.5676065853,
1.6314337483,
1.5089946653,
1.5408961823,
1.6555851813,
1.5751253693,
1.5789429713,
1.6113100123000001,
1.5792668893,
1.5691780553,
1.5274483612999998,
1.6164811452999999,
1.5324931943,
1.6186490903,
1.5466038762999998,
1.6704481293,
1.6247100733,
1.5427539253,
1.6168075493,
1.6188093963,
1.6029602562999998,
1.5761420792999998,
1.5433073123,
1.6179796743,
1.6175545353,
1.6318414422999998,
1.5538511703,
1.5957183363,
1.5548314073,
1.5846359743,
1.6423108263000001,
1.5467988902999998,
1.5631220852999999,
1.5742669633,
1.5770932183,
1.6208351293,
1.5558609233,
1.6271851523,
1.6104170183,
1.6231884473,
1.5770617583,
1.5504421173,
1.6021042633,
1.6312162983,
1.6721914603,
1.5393533342999999,
1.6380897473,
1.6382059013,
1.6621236303,
1.5422585533,
1.6554498563,
1.5422890693,
1.6140952273
],
"exit_codes": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
}
]
}

View File

@ -0,0 +1,218 @@
{
"results": [
{
"command": "python vicky_py/d01p1.py",
"mean": 0.015132811449999992,
"stddev": 0.0007816237374053428,
"median": 0.01486825428,
"user": 0.01270832,
"system": 0.0024101320000000006,
"min": 0.01436241278,
"max": 0.01817732678,
"times": [
0.015518389779999999,
0.01813885378,
0.01605782678,
0.015091580779999999,
0.01528983678,
0.01696367778,
0.01786692578,
0.01604522378,
0.01791159778,
0.01666651378,
0.01663513578,
0.01817732678,
0.01534427378,
0.015055749779999999,
0.014746743779999998,
0.01504438278,
0.014920876779999998,
0.01509644178,
0.01491007578,
0.01587278678,
0.01463246978,
0.015096525779999998,
0.01599748078,
0.01464660278,
0.01487039578,
0.014966278779999998,
0.01553397178,
0.01450562678,
0.01472500278,
0.01479079878,
0.014613496779999999,
0.015052138779999998,
0.015068220779999999,
0.01485035878,
0.01612641578,
0.014659551779999998,
0.014462230779999998,
0.014704591779999998,
0.01579260378,
0.01493656178,
0.014439517780000001,
0.01479319778,
0.01484612778,
0.01487984078,
0.015270242779999998,
0.01478750878,
0.01454116578,
0.01481142378,
0.01486611278,
0.01459962078,
0.015146284779999998,
0.01513184078,
0.014671047779999998,
0.01490411278,
0.01516517878,
0.014547937779999999,
0.01611687378,
0.01479300478,
0.014642981780000001,
0.014990844779999998,
0.01469972478,
0.01436241278,
0.01498505578,
0.015351252780000001,
0.01476563778,
0.01467167778,
0.014857947779999998,
0.014770485779999998,
0.01495125478,
0.014514572779999999,
0.014705532779999999,
0.01481573278,
0.015126245779999999,
0.01509372078,
0.014702891780000001,
0.01464654378,
0.01560098478,
0.01631168578,
0.014627815780000001,
0.01476084078,
0.01483350478,
0.01441758378,
0.01484819678,
0.01461456078,
0.01516131078,
0.01521244678,
0.014570058779999999,
0.01467177078,
0.014837039779999998,
0.014570898780000001,
0.014939095779999998,
0.014654438780000001,
0.014765305779999998,
0.01481357178,
0.01483872578,
0.014888913779999999,
0.014661001779999999,
0.014468301779999998,
0.01495531478,
0.01490667378
],
"exit_codes": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
}
]
}

View File

@ -0,0 +1,218 @@
{
"results": [
{
"command": "python vicky_py/d02p1.py",
"mean": 0.77773528433,
"stddev": 0.013976194777421366,
"median": 0.7759338516400001,
"user": 0.7699287800000004,
"system": 0.004225879999999999,
"min": 0.7490998936400001,
"max": 0.8399190376400001,
"times": [
0.75979596264,
0.7661285686400001,
0.7791226626400001,
0.7490998936400001,
0.7736369176400001,
0.7641418486400001,
0.7793006606400001,
0.76434331064,
0.7799637526400001,
0.7607602726400001,
0.7741888416400001,
0.7949796806400001,
0.77305558764,
0.8012396196400001,
0.77498808364,
0.7862997626400001,
0.7847444226400001,
0.7619847626400001,
0.7837266866400001,
0.7846942496400001,
0.7856272536400001,
0.76538022664,
0.78913555164,
0.7838882036400001,
0.7873134206400001,
0.7824590946400001,
0.7804697756400001,
0.8059732046400001,
0.7866213446400001,
0.7741237476400001,
0.7890587036400001,
0.7789373526400001,
0.7876874266400001,
0.7739823786400001,
0.7752962816400001,
0.7718479856400001,
0.7743720316400001,
0.7731203976400001,
0.7877970456400001,
0.7777499686400001,
0.7680522996400001,
0.7730276016400001,
0.7765714216400001,
0.8324236546400001,
0.7672744766400001,
0.78282582864,
0.7674357836400001,
0.7732558296400001,
0.7678108906400001,
0.77327789964,
0.7674461176400001,
0.7695352836400001,
0.76425323864,
0.7801603266400001,
0.7820577376400001,
0.7893313496400001,
0.7787597436400001,
0.7805181096400001,
0.7672512906400001,
0.7734224456400001,
0.7776302256400001,
0.7647321746400001,
0.7856538736400001,
0.77927853564,
0.8056057246400001,
0.7644001326400001,
0.7673602426400001,
0.7926977196400001,
0.78798424064,
0.76219117564,
0.7637820096400001,
0.7819979216400001,
0.7680101816400001,
0.79594539764,
0.76706916164,
0.7856222366400001,
0.7865205376400001,
0.7643969076400001,
0.7915279496400001,
0.76369593564,
0.7808402326400001,
0.7636531946400001,
0.7681546326400001,
0.7705579516400001,
0.7829478466400001,
0.7934510776400001,
0.76480994964,
0.7774967666400001,
0.7612722326400001,
0.7751671836400001,
0.7646966886400001,
0.7931756816400001,
0.7779745056400001,
0.7818194916400001,
0.7597408616400001,
0.8020904466400001,
0.7604263216400001,
0.8399190376400001,
0.7654483126400001,
0.7720554586400001
],
"exit_codes": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
}
]
}

View File

@ -0,0 +1,218 @@
{
"results": [
{
"command": "python vicky_py/d02p2.py",
"mean": 8.94538261009,
"stddev": 0.2509496444217131,
"median": 9.049778934679999,
"user": 8.905039219999999,
"system": 0.004360440000000002,
"min": 8.43330605468,
"max": 9.28971549368,
"times": [
8.88167304868,
8.46350218868,
8.67955974168,
9.20559683968,
9.04275455968,
8.53011481668,
9.113910668679999,
8.67396180568,
8.98211474468,
9.13243384468,
8.54408974368,
9.16571656168,
9.07330562868,
9.04507466068,
9.12033452368,
8.50616699068,
9.23906340268,
9.12349666168,
8.96128319468,
9.22774800968,
8.95911522268,
9.09715083468,
8.99449587868,
9.12981722168,
9.16881575368,
9.10937898368,
8.59131431268,
9.149065372679999,
9.11519702468,
8.97529310268,
9.11304015268,
8.57284944868,
9.05109928568,
9.11348437868,
9.24477652068,
9.13321668068,
9.08530538368,
9.10167634968,
8.96956938268,
9.03289946468,
9.11982480368,
9.10569408068,
9.03393993968,
9.14796976468,
9.10120584068,
8.91329725468,
8.98842096568,
9.08925683468,
9.01037838268,
8.97055297668,
9.12851075668,
8.76169907768,
8.61325028268,
9.25796331068,
8.65943359468,
9.09327849968,
8.50863367768,
9.08476618868,
8.54501605568,
9.22169484968,
9.12108713468,
8.63231732268,
9.17397773768,
9.20391244368,
8.55778174668,
8.68909028968,
9.18076122568,
9.11404111068,
8.65173546368,
9.27378586668,
8.65780827568,
9.14613413768,
8.67141103168,
9.21394277068,
9.20651857668,
8.55610273368,
8.68119686368,
9.15976400568,
8.57780606068,
9.21236916268,
9.09689742368,
8.59434178568,
9.20229382068,
8.71541957368,
8.58779979768,
9.04920293768,
8.58982091168,
9.28971549368,
8.52752932968,
9.08155105168,
9.05035493168,
8.59374959768,
8.58687716468,
9.02231053868,
9.12043051868,
8.49205575768,
9.05606913268,
8.96841341868,
9.02432827768,
8.43330605468
],
"exit_codes": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

11
bram/benchmarks/vicky.sh Normal file
View File

@ -0,0 +1,11 @@
# Benchmark day 1
hyperfine --warmup 5 --export-json data/vicky-d01-p1.json --runs 100 \
"python vicky_py/d01p1.py"
# hyperfine --warmup 5 --export-json data/vicky-d01-p2.json --runs 100 \
# "python vicky_py/d01p2.py"
# Benchmark day 2
hyperfine --warmup 5 --export-json data/vicky-d02-p1.json --runs 100 \
"python vicky_py/d02p1.py"
hyperfine --warmup 5 --export-json data/vicky-d02-p2.json --runs 100 \
"python vicky_py/d02p2.py"

View File

@ -0,0 +1,47 @@
#!/usr/bin/env python
# coding: utf-8
# # Puzzle 1 of AoC 2025
# Author: Victoria Ramírez López
#
# Date: December 1, 2025
# In[89]:
def rotate_dial(instruction = '', dial_position=50):
# This function rotates the dial based on the input from the set of instructions
# input: instruction = String
# output: dial_position
# Split the instruction into "direction" and "distance"
direction = instruction[0]
distance = int(instruction[1:])
# Calculate final position of the dial
if direction == 'R':
dial_position = (dial_position + distance) % 100
elif direction == 'L':
dial_position = (dial_position - distance) % 100
return dial_position
# In[97]:
# Import instruction file
instructions = open('vicky_py/input01.txt','r')
# In[98]:
# Calculate passcode
dial_position = 50
passcode = 0
for instruction in instructions:
dial_position = rotate_dial(instruction, dial_position)
if dial_position == 0:
passcode = passcode + 1
print(passcode)

View File

@ -0,0 +1,133 @@
#!/usr/bin/env python
# coding: utf-8
# # Puzzle 2 of AoC 2025
# Author: Victoria Ramírez López
#
# Date: Dec 2, 2025
# In[18]:
def find_invalid_ids(id_range=''):
# This function finds the invalid ids within the specified range (part 1)
# input: id_range = String
# output: invalid_ids = int []
invalid_ids = []
invalid_id = []
# Extract the upper and lower bounds of the range
lb = int(id_range.split('-')[0])
ub = int(id_range.split('-')[1]) + 1
# Generate the series of product ids withing the range
product_ids = range(lb,ub)
# Find invalid ids
for id in product_ids:
id_string = str(id) # Convert each product id to string
if len(id_string) % 2 == 0:
middle_point = len(id_string) // 2 # Find where to split the product id in 2
# Compare the two halves of the id to determine if the id is invalid
first_half = id_string[0:middle_point]
second_half = id_string[middle_point:]
if first_half == second_half: # If the two halves are equal, the id is invalid
invalid_id = int(id_string)
invalid_ids.append(invalid_id)
return invalid_ids
# In[33]:
def chop_product_id(id):
# This function chops a product id into chunks of equal sizes
# input: id = int
# output: chopped_id = [[]]
id_string = str(id)
chunks = []
chopped_id = []
# Find divisors to split the id into equal-sized chunks
# (aka: how many ways to split the id into equal-sized chunks are there?)
for divisor in range(2,len(id_string) + 1):
if len(id_string) % divisor == 0:
chunks = []
chunk_size = len(id_string) // divisor # Determine how big a chunk would be
for i in range(1,len(id_string)+1,chunk_size): # Chop the id
chunk = id_string[i-1:(i-1 + chunk_size)]
chunks.append(chunk)
chopped_id.append(chunks)
return chopped_id
# In[49]:
# Read product ID ranges file
import csv
input_file = open('../rust/inputs/02.txt', mode ='r') # Open in 'read only' mode
id_ranges_csv = csv.reader(input_file)
id_ranges_list = list(id_ranges_csv)
# In[51]:
def find_all_invalid_ids(id_range=''):
# This function finds all the invalid ids within the specified range (part 2)
# input: id_range = String
# output: invalid_ids = int [[]]
invalid_ids = []
invalid_id = []
# Extract the upper and lower bounds of the range
lb = int(id_range.split('-')[0])
ub = int(id_range.split('-')[1]) + 1
# Generate the series of product ids withing the range
product_ids = range(lb,ub)
# Find invalid ids
for id in product_ids:
id_string = str(id) # Convert each product id to string
chopped_ids = chop_product_id(id) # Chop each product id into equal-sized pieces
# Identify ids with a repeating pattern
for list in chopped_ids:
chunks_set = set(list) # Convert each group of equal-sized chunks into a set
if len(chunks_set) == 1: # If the resulting set has only 1 element, the id is invalid
invalid_id = int(id_string)
invalid_ids.append(invalid_id)
break
return(invalid_ids)
# In[52]:
# Get invalid ids and calculate answer
invalid_ids = []
id_ranges = []
for id_range in id_ranges_list[0]:
invalid_ids_range = find_invalid_ids(id_range) # For part 1 answer
# invalid_ids_range = find_all_invalid_ids(id_range) # For part 2 answer
invalid_ids.append(invalid_ids_range[:])
sum_invalid_ids = sum(sum(invalid_ids,[]))
# print(invalid_ids)
print(sum_invalid_ids)

View File

@ -0,0 +1,133 @@
#!/usr/bin/env python
# coding: utf-8
# # Puzzle 2 of AoC 2025
# Author: Victoria Ramírez López
#
# Date: Dec 2, 2025
# In[18]:
def find_invalid_ids(id_range=''):
# This function finds the invalid ids within the specified range (part 1)
# input: id_range = String
# output: invalid_ids = int []
invalid_ids = []
invalid_id = []
# Extract the upper and lower bounds of the range
lb = int(id_range.split('-')[0])
ub = int(id_range.split('-')[1]) + 1
# Generate the series of product ids withing the range
product_ids = range(lb,ub)
# Find invalid ids
for id in product_ids:
id_string = str(id) # Convert each product id to string
if len(id_string) % 2 == 0:
middle_point = len(id_string) // 2 # Find where to split the product id in 2
# Compare the two halves of the id to determine if the id is invalid
first_half = id_string[0:middle_point]
second_half = id_string[middle_point:]
if first_half == second_half: # If the two halves are equal, the id is invalid
invalid_id = int(id_string)
invalid_ids.append(invalid_id)
return invalid_ids
# In[33]:
def chop_product_id(id):
# This function chops a product id into chunks of equal sizes
# input: id = int
# output: chopped_id = [[]]
id_string = str(id)
chunks = []
chopped_id = []
# Find divisors to split the id into equal-sized chunks
# (aka: how many ways to split the id into equal-sized chunks are there?)
for divisor in range(2,len(id_string) + 1):
if len(id_string) % divisor == 0:
chunks = []
chunk_size = len(id_string) // divisor # Determine how big a chunk would be
for i in range(1,len(id_string)+1,chunk_size): # Chop the id
chunk = id_string[i-1:(i-1 + chunk_size)]
chunks.append(chunk)
chopped_id.append(chunks)
return chopped_id
# In[49]:
# Read product ID ranges file
import csv
input_file = open('../rust/inputs/02.txt', mode ='r') # Open in 'read only' mode
id_ranges_csv = csv.reader(input_file)
id_ranges_list = list(id_ranges_csv)
# In[51]:
def find_all_invalid_ids(id_range=''):
# This function finds all the invalid ids within the specified range (part 2)
# input: id_range = String
# output: invalid_ids = int [[]]
invalid_ids = []
invalid_id = []
# Extract the upper and lower bounds of the range
lb = int(id_range.split('-')[0])
ub = int(id_range.split('-')[1]) + 1
# Generate the series of product ids withing the range
product_ids = range(lb,ub)
# Find invalid ids
for id in product_ids:
id_string = str(id) # Convert each product id to string
chopped_ids = chop_product_id(id) # Chop each product id into equal-sized pieces
# Identify ids with a repeating pattern
for list in chopped_ids:
chunks_set = set(list) # Convert each group of equal-sized chunks into a set
if len(chunks_set) == 1: # If the resulting set has only 1 element, the id is invalid
invalid_id = int(id_string)
invalid_ids.append(invalid_id)
break
return(invalid_ids)
# In[52]:
# Get invalid ids and calculate answer
invalid_ids = []
id_ranges = []
for id_range in id_ranges_list[0]:
# invalid_ids_range = find_invalid_ids(id_range) # For part 1 answer
invalid_ids_range = find_all_invalid_ids(id_range) # For part 2 answer
invalid_ids.append(invalid_ids_range[:])
sum_invalid_ids = sum(sum(invalid_ids,[]))
# print(invalid_ids)
print(sum_invalid_ids)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
8123221734-8123333968,2665-4538,189952-274622,4975-9031,24163352-24202932,1233-1772,9898889349-9899037441,2-15,2147801-2281579,296141-327417,8989846734-8989940664,31172-42921,593312-632035,862987-983007,613600462-613621897,81807088-81833878,13258610-13489867,643517-782886,986483-1022745,113493-167913,10677-16867,372-518,3489007333-3489264175,1858-2534,18547-26982,16-29,247-366,55547-103861,57-74,30-56,1670594-1765773,76-129,134085905-134182567,441436-566415,7539123416-7539252430,668-1146,581563513-581619699

View File

@ -1,55 +1,41 @@
use crate::utils; use crate::utils;
struct Dial { pub fn answer(text : String) ->( u16, u16 ) {
points_at : i16, let mut old : i16 = 50;
clicks : u32, let mut clicks : u16 = 0;
passing_clicks : u32, let mut passing_clicks : u16 = 0;
}
impl Dial {
fn new() -> Dial {
Dial { points_at : 50, clicks : 0, passing_clicks : 0 }
}
fn rotate_by(&mut self, r : i16) -> () {
let start : i16 = self.points_at;
self.points_at += r;
self.points_at = self.points_at.rem_euclid(100);
self.passing_clicks += (r.abs() / 100) as u32;
if self.points_at == 0 {
self.clicks += 1;
// Avoid double counting when starting and landing on zero
if r / 100 != 0 && r % 100 == 0 {
self.passing_clicks -= 1;
}
}
if r < 0 && start < self.points_at && start != 0 {
self.passing_clicks += 1;
}
if r > 0 && start > self.points_at && self.points_at != 0 {
self.passing_clicks += 1;
}
// println!(
// "Dial {} now points at {} ({} clicks, {} passing)",
// r, self.points_at, self.clicks, self.passing_clicks
// );
}
}
pub fn answer(text : String) ->( u32, u32 ) {
let mut dial : Dial = Dial::new();
for d in text.split("\n").filter_map(str_to_dir) { for d in text.split("\n").filter_map(str_to_dir) {
dial.rotate_by(d); let new : i16 = old + d;
// Part 1 clicks
if new % 100 == 0 {
clicks += 1;
}
// Part 2 clicks
if d > 0 {
passing_clicks += (
new.div_euclid(100) - old.div_euclid(100)
) as u16
} else {
passing_clicks += (
(old - 1).div_euclid(100) - (new - 1).div_euclid(100)
) as u16
}
old = new;
} }
( dial.clicks ( clicks, passing_clicks )
, dial.clicks + dial.passing_clicks }
)
fn count_passing_clicks(old : i16, new : i16) -> u16 {
if old < new {
(new.div_euclid(100) - old.div_euclid(100)).abs() as u16
} else {
((new - 1).div_euclid(100) - (old - 1).div_euclid(100)).abs() as u16
}
} }
fn str_to_dir(s : &str) -> Option<i16> { fn str_to_dir(s : &str) -> Option<i16> {

View File

@ -0,0 +1,50 @@
use crate::utils;
use std::ops::RangeInclusive;
pub fn answer(text : String) -> ( u64, u64 ) {
( text.split(",").flat_map(to_range).filter(|x| is_invalid_by(x, 2)).sum()
, text.split(",").flat_map(to_range).filter(is_invalid).sum()
)
}
fn is_invalid(n : &u64) -> bool {
for b in 2..=10 {
if is_invalid_by(n, b) {
return true;
}
}
false
}
fn is_invalid_by(n : &u64, by : usize) -> bool {
let s : String = n.to_string();
let size : usize = s.len() / by;
if s.len() % by == 0 {
for i in 1..by {
if s[0..size] != s[i * size..(i + 1) * size] {
return false;
}
}
true
} else {
false
}
}
fn to_range(s : &str) -> RangeInclusive<u64> {
let empty = 1..=0;
if let Some((low, high)) = s.split_once("-") {
match ( utils::str_to_u64(low), utils::str_to_u64(high) ) {
( Some(l), Some(h) ) =>
l..=h,
_ =>
// Empty iterator
empty,
}
} else {
empty
}
}

View File

@ -1,5 +1,5 @@
mod day_01; mod day_01;
// mod day_02; mod day_02;
// mod day_03; // mod day_03;
// mod day_04; // mod day_04;
// mod day_05; // mod day_05;
@ -26,12 +26,12 @@ pub fn day_01() -> DailyOutput {
( p1 as u128, p2 as u128, d ) ( p1 as u128, p2 as u128, d )
} }
// pub fn day_02() -> DailyOutput { pub fn day_02() -> DailyOutput {
// let s : String = read_from_file("inputs/02.txt"); let s : String = read_from_file("inputs/02.txt");
// let (p1, p2, d) = diagnostics::benchmark(s, day_02::answer); let (p1, p2, d) = diagnostics::benchmark(s, day_02::answer);
// ( p1 as u128, p2 as u128, d ) ( p1 as u128, p2 as u128, d )
// } }
// pub fn day_03() -> DailyOutput { // pub fn day_03() -> DailyOutput {
// let s : String = read_from_file("inputs/03.txt"); // let s : String = read_from_file("inputs/03.txt");

View File

@ -29,7 +29,7 @@ fn run_all_days() {
let mut aoc = aoc2025::AdventOfCode::new(); let mut aoc = aoc2025::AdventOfCode::new();
aoc.insert(1, aoc2025::day_01()); aoc.insert(1, aoc2025::day_01());
// aoc.insert(2, aoc2025::day_02()); aoc.insert(2, aoc2025::day_02());
// aoc.insert(3, aoc2025::day_03()); // aoc.insert(3, aoc2025::day_03());
// aoc.insert(4, aoc2025::day_04()); // aoc.insert(4, aoc2025::day_04());
// aoc.insert(5, aoc2025::day_05()); // aoc.insert(5, aoc2025::day_05());

View File

@ -36,6 +36,6 @@ pub fn str_to_i16(s : &str) -> Option<i16> {
// s.trim().to_string().parse::<u32>().ok() // s.trim().to_string().parse::<u32>().ok()
// } // }
// pub fn str_to_u64(s : &str) -> Option<u64> { pub fn str_to_u64(s : &str) -> Option<u64> {
// s.trim().to_string().parse::<u64>().ok() s.trim().to_string().parse::<u64>().ok()
// } }

19
brechtje/2/2-1.py Normal file
View File

@ -0,0 +1,19 @@
raw_input = open('input.txt', "r").read().split(',')
input = []
for item in raw_input:
input.append(item.split('-'))
answer = 0
invalid_numbers = []
for item in input:
for i in range(int(item[0]), int(item[1]) + 1):
str_i = str(i)
if len(str_i) % 2 == 0:
halfway = int(len(str_i)/2)
if str_i[0:halfway] == str_i[halfway:]:
answer += i
invalid_numbers.append(i)
print(answer)

50
brechtje/2/2-2.py Normal file
View File

@ -0,0 +1,50 @@
from itertools import pairwise
raw_input = open('input.txt', "r").read().split(',')
input = []
for item in raw_input:
input.append(item.split('-'))
answer = 0
invalid_numbers = []
for item in input:
for i in range(int(item[0]), int(item[1]) + 1):
str_i = str(i)
if len(str_i) % 2 == 0:
halfway = int(len(str_i)/2)
if str_i[0:halfway] == str_i[halfway:]:
answer += i
invalid_numbers.append(i)
continue
if len(str_i) % 3 == 0:
third = int(len(str_i)/3)
if str_i[0:third] == str_i[third:2 * third] == str_i[2 * third:]:
answer += i
invalid_numbers.append(i)
continue
if len(str_i) % 4 == 0:
quarter = int(len(str_i)/4)
if str_i[0:quarter] == str_i[quarter:halfway] == str_i[halfway:3 * quarter] == str_i[3 * quarter:]:
answer += i
invalid_numbers.append(i)
continue
if len(str_i) % 5 == 0:
fifth = int(len(str_i)/5)
if str_i[0:fifth] == str_i[fifth:2 * fifth] == str_i[2 * fifth:3 * fifth] == str_i[3 * fifth:4 * fifth] == str_i[4 * fifth:]:
answer += i
invalid_numbers.append(i)
continue
else:
all_the_same = True
for pair in pairwise(str_i):
if pair[0] != pair[1]:
all_the_same = False
break
if all_the_same:
answer += i
invalid_numbers.append(i)
print(invalid_numbers)
print(answer)

2
vicky/README.md Normal file
View File

@ -0,0 +1,2 @@
# Vicky's AoC folder
Welcome to my branch! :D

99
vicky/dec1/dec1.ipynb Normal file
View File

@ -0,0 +1,99 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "40aac862-406a-498f-8138-a93a3eca5aa8",
"metadata": {},
"source": [
"# Puzzle 1 of AoC 2025\n",
"Author: Victoria Ramírez López \n",
"\n",
"Date: December 1, 2025"
]
},
{
"cell_type": "code",
"execution_count": 97,
"id": "7545bee7-c72d-4755-a191-b0803ca31c11",
"metadata": {},
"outputs": [],
"source": [
"# Import instruction file\n",
"instructions = open('dummy_input.txt','r')"
]
},
{
"cell_type": "code",
"execution_count": 98,
"id": "87fab12e-84fd-4949-a914-ed722bd28737",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3\n"
]
}
],
"source": [
"# Calculate passcode\n",
"dial_position = 50\n",
"passcode = 0\n",
"\n",
"for instruction in instructions:\n",
" dial_position = rotate_dial(instruction, dial_position)\n",
" if dial_position == 0:\n",
" passcode = passcode + 1\n",
"\n",
"print(passcode)"
]
},
{
"cell_type": "code",
"execution_count": 89,
"id": "7689f8ae-6d8a-4116-8188-7678bfac793d",
"metadata": {},
"outputs": [],
"source": [
"def rotate_dial(instruction = '', dial_position=50):\n",
" # This function rotates the dial based on the input from the set of instructions\n",
" # input: instruction = String\n",
" # output: dial_position\n",
"\n",
" # Split the instruction into \"direction\" and \"distance\"\n",
" direction = instruction[0]\n",
" distance = int(instruction[1:])\n",
"\n",
" # Calculate final position of the dial\n",
" if direction == 'R':\n",
" dial_position = (dial_position + distance) % 100\n",
" elif direction == 'L':\n",
" dial_position = (dial_position - distance) % 100\n",
"\n",
" return dial_position"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

50
vicky/dec1/dec1.py Normal file
View File

@ -0,0 +1,50 @@
#!/usr/bin/env python
# coding: utf-8
# # Puzzle 1 of AoC 2025
# Author: Victoria Ramírez López
#
# Date: December 1, 2025
# In[97]:
# Import instruction file
instructions = open('dummy_input.txt','r')
# In[98]:
# Calculate passcode
dial_position = 50
passcode = 0
for instruction in instructions:
dial_position = rotate_dial(instruction, dial_position)
if dial_position == 0:
passcode = passcode + 1
print(passcode)
# In[89]:
def rotate_dial(instruction = '', dial_position=50):
# This function rotates the dial based on the input from the set of instructions
# input: instruction = String
# output: dial_position
# Split the instruction into "direction" and "distance"
direction = instruction[0]
distance = int(instruction[1:])
# Calculate final position of the dial
if direction == 'R':
dial_position = (dial_position + distance) % 100
elif direction == 'L':
dial_position = (dial_position - distance) % 100
return dial_position

View File

@ -0,0 +1,10 @@
L68
L30
R48
L5
R60
L55
L1
L99
R14
L82

4387
vicky/dec1/input_dec1.txt Normal file

File diff suppressed because it is too large Load Diff

194
vicky/dec2/dec2.ipynb Normal file

File diff suppressed because one or more lines are too long

136
vicky/dec2/dec2.py Normal file
View File

@ -0,0 +1,136 @@
#!/usr/bin/env python
# coding: utf-8
# # Puzzle 2 of AoC 2025
# Author: Victoria Ramírez López
#
# Date: Dec 2, 2025
# In[49]:
# Read product ID ranges file
import csv
input_file = open('product_id_ranges.txt', mode ='r') # Open in 'read only' mode
id_ranges_csv = csv.reader(input_file)
id_ranges_list = list(id_ranges_csv)
# In[52]:
# Get invalid ids and calculate answer
invalid_ids = []
id_ranges = []
for id_range in id_ranges_list[0]:
# invalid_ids_range = find_invalid_ids(id_range) # For part 1 answer
invalid_ids_range = find_all_invalid_ids(id_range) # For part 2 answer
invalid_ids.append(invalid_ids_range[:])
sum_invalid_ids = sum(sum(invalid_ids,[]))
# print(invalid_ids)
print(sum_invalid_ids)
# In[18]:
def find_invalid_ids(id_range=''):
# This function finds the invalid ids within the specified range (part 1)
# input: id_range = String
# output: invalid_ids = int []
invalid_ids = []
invalid_id = []
# Extract the upper and lower bounds of the range
lb = int(id_range.split('-')[0])
ub = int(id_range.split('-')[1]) + 1
# Generate the series of product ids withing the range
product_ids = range(lb,ub)
# Find invalid ids
for id in product_ids:
id_string = str(id) # Convert each product id to string
if len(id_string) % 2 == 0:
middle_point = len(id_string) // 2 # Find where to split the product id in 2
# Compare the two halves of the id to determine if the id is invalid
first_half = id_string[0:middle_point]
second_half = id_string[middle_point:]
if first_half == second_half: # If the two halves are equal, the id is invalid
invalid_id = int(id_string)
invalid_ids.append(invalid_id)
return invalid_ids
# In[51]:
def find_all_invalid_ids(id_range=''):
# This function finds all the invalid ids within the specified range (part 2)
# input: id_range = String
# output: invalid_ids = int [[]]
invalid_ids = []
invalid_id = []
# Extract the upper and lower bounds of the range
lb = int(id_range.split('-')[0])
ub = int(id_range.split('-')[1]) + 1
# Generate the series of product ids withing the range
product_ids = range(lb,ub)
# Find invalid ids
for id in product_ids:
id_string = str(id) # Convert each product id to string
chopped_ids = chop_product_id(id) # Chop each product id into equal-sized pieces
# Identify ids with a repeating pattern
for list in chopped_ids:
chunks_set = set(list) # Convert each group of equal-sized chunks into a set
if len(chunks_set) == 1: # If the resulting set has only 1 element, the id is invalid
invalid_id = int(id_string)
invalid_ids.append(invalid_id)
break
return(invalid_ids)
# In[33]:
def chop_product_id(id):
# This function chops a product id into chunks of equal sizes
# input: id = int
# output: chopped_id = [[]]
id_string = str(id)
chunks = []
chopped_id = []
# Find divisors to split the id into equal-sized chunks
# (aka: how many ways to split the id into equal-sized chunks are there?)
for divisor in range(2,len(id_string) + 1):
if len(id_string) % divisor == 0:
chunks = []
chunk_size = len(id_string) // divisor # Determine how big a chunk would be
for i in range(1,len(id_string)+1,chunk_size): # Chop the id
chunk = id_string[i-1:(i-1 + chunk_size)]
chunks.append(chunk)
chopped_id.append(chunks)
return chopped_id

View File

@ -0,0 +1 @@
11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,446443-446449,38593856-38593862,565653-565659,824824821-824824827,2121212118-2121212124

View File

@ -0,0 +1 @@
959516-995437,389276443-389465477,683-1336,15687-26722,91613-136893,4-18,6736-12582,92850684-93066214,65-101,6868676926-6868700146,535033-570760,826141-957696,365650-534331,1502-2812,309789-352254,79110404-79172400,18286593-18485520,34376-65398,26-63,3333208697-3333457635,202007-307147,1859689-1936942,9959142-10053234,2318919-2420944,5142771457-5142940464,1036065-1206184,46314118-46413048,3367-6093,237-481,591751-793578