Compare commits

...

30 Commits

Author SHA1 Message Date
Bram 3be30b2a14 Add updated .gitignore + benchmarks to Bram's branch 2025-12-03 22:10:54 +01:00
Bram bd8a50df82 Add day 1 solutions 2025-12-03 22:06:20 +01:00
Bram 3faee72c5d Optimize & simplify day 3 2025-12-03 10:56:33 +01:00
Bram 4ae1fea299 Fix compiler warnings 2025-12-03 09:17:36 +01:00
Bram 0fd6e45b5e Add day 3 (rough version) 2025-12-03 08:57:43 +01:00
Bram 5c55c53f41 Visualize day 1 benchmarks 2025-12-02 11:21:37 +01:00
Bram 500c885da6 Add Sander's day 1 benchmarks 2025-12-02 00:37:58 +01:00
Bram 9139bf11fc Merge Sander's branch into benchmark branch 2025-12-02 00:20:52 +01:00
Bram 203ed61e24 Add Haskell & Ruby to .gitignore 2025-12-02 00:01:27 +01:00
Bram fa3893e372 Add Brechtje's day 1 benchmarks 2025-12-01 23:56:07 +01:00
Bram 6a253d294c Merge Brechtje's branch into benchmark branch 2025-12-01 23:43:42 +01:00
Brechtje van Gessel 3adc1f38b9 added .txt files in subfolders of the brechtje folder to gitignore 2025-12-01 23:43:02 +01:00
Brechtje van Gessel f870bbd03f added .txt files to gitignore for brechtje folder 2025-12-01 23:39:31 +01:00
Bram a5f45c2230 Add Bob's day 1 benchmarks 2025-12-01 23:31:31 +01:00
Bram 992268ab47 Merge Bob's branch into benchmark branch 2025-12-01 23:23:38 +01:00
Sander 35243b8b50 Update sander/AoC 2025 2025-12-01 22:19:39 +00:00
Sander a2fe8b86ee Update sander/AoC 2025 2025-12-01 21:51:57 +00:00
Brechtje van Gessel 325b32655a solved day 1 part 2 2025-12-01 22:37:14 +01:00
Bram e35bb1b68e Add Bram's day 1 benchmarks 2025-12-01 17:30:38 +01:00
Bram 32bacbeb1d Add args to Rust program to run individual days 2025-12-01 17:13:18 +01:00
Brechtje van Gessel a11800d0d7 attempt 1 2025-12-01 17:06:32 +01:00
Bob 9aa6a02fdf day01 2025-12-01 16:40:04 +01:00
Brechtje van Gessel 0118bf9920 solved day 1 part 1 2025-12-01 09:21:18 +01:00
Brechtje van Gessel 1030b26b31 first attempt, answer too low 2025-12-01 09:14:39 +01:00
Bob 43246bbe76 Simple README 2025-11-27 18:07:00 +01:00
Sander 01a11ad970 initial setup 2025-11-25 18:46:53 +00:00
Sander 0c3541d98a Update sander/AoC 2025 2025-11-25 18:23:13 +00:00
Sander 68d43244fd Update sander/day1 2025-11-25 17:32:48 +00:00
Sander 35df161c0c Update day1 2025-11-25 17:32:38 +00:00
Sander d5b48edffb sander 2025-11-25 16:02:23 +00:00
35 changed files with 6514 additions and 16 deletions

85
.gitignore vendored
View File

@ -58,6 +58,31 @@ elm-stuff
# elm-repl generated files
repl-temp-*
# ---> Haskell
dist
dist-*
cabal-dev
*.o
*.hi
*.hie
*.chi
*.chs.h
*.dyn_o
*.dyn_hi
.hpc
.hsenv
.cabal-sandbox/
cabal.sandbox.config
*.prof
*.aux
*.hp
*.eventlog
.stack-work/
cabal.project.local
cabal.project.local~
.HTF/
.ghc.environment.*
# ---> MATLAB
# Windows default autosave extension
*.asv
@ -253,6 +278,64 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# ---> Ruby
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
/tmp/
# Used by dotenv library to load environment variables.
# .env
# Ignore Byebug command history file.
.byebug_history
## Specific to RubyMotion:
.dat*
.repl_history
build/
*.bridgesupport
build-iPhoneOS/
build-iPhoneSimulator/
## Specific to RubyMotion (use of CocoaPods):
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# vendor/Pods/
## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/
## Environment normalization:
/.bundle/
/vendor/bundle
/lib/bundler/man/
# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
# .rubocop-https?--*
# ---> Rust
# Generated by Cargo
# will have compiled files and executables
@ -270,6 +353,8 @@ Cargo.lock
*.pdb
# ---> Custom files
bram/benchmarks/sander_hs/bin
brechtje/**/*.txt
# If your structure requires you to ignore certain files or folders,
# you may add them here.

3
bob/README.md Normal file
View File

@ -0,0 +1,3 @@
# AOC 2025
This folder hosts the code written by Bob

36
bob/day01/day01-p1.py Normal file
View File

@ -0,0 +1,36 @@
def dial(action, position):
if action[0] == "R":
position += action[1]
else:
position -= action[1]
position = position % 100
return position
def read_input(filename):
actions = []
for line in open(filename):
line = line.strip()
direction = line[:1]
steps = int(line[1:])
actions.append((direction,steps))
return actions
# filename = "day01/my_example_input"
# filename = "day01/example_input" # Output is 3
filename = "day01/input" # Output is 992
actions = read_input(filename)
position = 50
password = 0
for action in actions:
position = dial(action, position)
if position == 0:
password += 1
print(f"Password is {password}")

44
bob/day01/day01-p2.py Normal file
View File

@ -0,0 +1,44 @@
def dial(action, start_position):
if action[0] == "R":
position = start_position + action[1]
else:
position = start_position - action[1]
# Count rotations over "0" (multiples of 100)
zeros = int(abs(position) / 100)
# Negative position, or exactly "0", caused one extra "0" hit
# Except when starting at 0!
if position <= 0 and start_position != 0:
zeros += 1
position = position % 100
return position, zeros
def read_input(filename):
actions = []
for line in open(filename):
line = line.strip()
direction = line[:1]
steps = int(line[1:])
actions.append((direction,steps))
return actions
# filename = "day01/my_example_input"
# filename = "day01/example_input" # Output is 6
filename = "day01/input" # Output is 6133
actions = read_input(filename)
position = 50
password = 0
for action in actions:
position, zeros = dial(action, position)
password += zeros
print(f"Password is {password}")

10
bob/day01/example_input Normal file
View File

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

4232
bob/day01/input Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
L50
L5

File diff suppressed because one or more lines are too long

39
bram/benchmarks/README.md Normal file
View File

@ -0,0 +1,39 @@
# Benchmarking setup
In this folder, I run some benchmarks on everyone's code.
## How to benchmark
1. Make sure you have the appropriate software installed. You can do so by
activating the Nix shell as defined in `shell.nix`, or you can view everyone's
installation requirements in the
[software requirements](#Software-requirements) section.
2. Run benchmarks by executing the respective scripts. For example, if you
wish to benchmark Bram's code, you may run `bram.sh` in your terminal. All data
will be collected in the `data/` folder.
3. Once you have collected all the data you wanted to collect, you can open the
Jupyter Notebook by typing `jupyter notebook Benchmarks.ipynb` in the terminal.
4. In the Jupyter Notebook, evaluate all cells and gain the graphs you want.
Graphs are also stored in the `img/` folder.
## Software requirements
To create the measurements, this benchmarking setup uses
[hyperfine](https://github.com/sharkdp/hyperfine). To build the visualization,
this setup uses [Jupyter Notebooks](https://jupyter.org/) - but you can install
the dependencies listed in `requirements.txt` to get all necessary packages
installed.
Bob uses [Python](https://www.python.org/).
Bram uses [Rust](https://rust-lang.org/) at version 1.86.0.
Brechtje uses [Python](https://www.python.org/).
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
liberties are taken here. The script is reformatted in the `sander_hs/` folder
and compiled to a binary in order to approximate performance.

9
bram/benchmarks/bob.sh Normal file
View File

@ -0,0 +1,9 @@
cd ../../bob
# Benchmark day 1
hyperfine --warmup 5 --export-json ../bram/benchmarks/data/bob-d01-p1.json \
--runs 100 "python day01/day01-p1.py"
hyperfine --warmup 5 --export-json ../bram/benchmarks/data/bob-d01-p2.json \
--runs 100 "python day01/day01-p2.py"
cd ../bram/benchmarks

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

@ -0,0 +1,11 @@
# Move to the appropriate folder
cd ../rust
# Build binary
cargo build --release
# Benchmark day 1
hyperfine --warmup 5 --export-json ../benchmarks/data/bram-d01-100.json \
--runs 100 "for run in {1..100}; do target/release/aoc2025 1; done"
cd ../benchmarks

View File

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

View File

@ -0,0 +1,29 @@
import json
DIRECTORY = []
with open("data/all.json", "r") as fp:
DIRECTORY = json.load(fp)
def generate_datafile(obj):
path = "data/" + obj["name"]
with open(path, 'r') as fp:
benchmark = json.load(fp)
for time in benchmark["results"][0]["times"]:
yield {
"author": obj["author"],
"lang": obj["lang"],
"time": time / obj["runs"],
}
def generate_day(day : int):
for part in [ 1, 2 ]:
for measurement in generate_puzzle(f"{day}-{part}"):
measurement["part"] = part
yield measurement
def generate_puzzle(puzzle : str):
for obj in DIRECTORY:
if puzzle in obj["puzzles"]:
yield from generate_datafile(obj)

View File

@ -0,0 +1,57 @@
[
{
"name": "bob-d01-p1.json",
"author": "Bob",
"lang": "Python",
"puzzles": [
"1-1"
],
"runs": 1
},
{
"name": "bob-d01-p2.json",
"author": "Bob",
"lang": "Python",
"puzzles": [
"1-2"
],
"runs": 1
},
{
"name": "bram-d01-100.json",
"author": "Bram",
"lang": "Rust",
"puzzles": [
"1-1",
"1-2"
],
"runs": 100
},
{
"name": "brechtje-d01-p1.json",
"author": "Brechtje",
"lang": "Python",
"puzzles": [
"1-1"
],
"runs": 1
},
{
"name": "brechtje-d01-p2.json",
"author": "Brechtje",
"lang": "Python",
"puzzles": [
"1-2"
],
"runs": 1
},
{
"name": "sander-d01-p1.json",
"author": "Sander",
"lang": "Haskell",
"puzzles": [
"1-1"
],
"runs": 1
}
]

View File

@ -0,0 +1,218 @@
{
"results": [
{
"command": "python day01/day01-p1.py",
"mean": 0.018280616970000003,
"stddev": 0.0006054695984127279,
"median": 0.018186844940000002,
"user": 0.01483600999999999,
"system": 0.0033221896000000008,
"min": 0.017335730940000002,
"max": 0.020703820940000003,
"times": [
0.01807126494,
0.01766033694,
0.01770073494,
0.02004624194,
0.018178473940000002,
0.018417852940000003,
0.01812796494,
0.017955673940000003,
0.018379266940000003,
0.01809406594,
0.018453467940000003,
0.01802611594,
0.018267693940000003,
0.01793643794,
0.01828018094,
0.018444996940000003,
0.018143806940000003,
0.019526113940000003,
0.01844583894,
0.019931652940000003,
0.018626267940000003,
0.018122100940000004,
0.018915561940000002,
0.018065865940000002,
0.018375352940000002,
0.019079646940000004,
0.020026991940000002,
0.01761536094,
0.020703820940000003,
0.01825914994,
0.01748083594,
0.01893691494,
0.01743567994,
0.018392330940000003,
0.018382992940000002,
0.018990103940000003,
0.018086712940000003,
0.01733794194,
0.018799991940000003,
0.01816632794,
0.01769464394,
0.01754049594,
0.018241162940000003,
0.017692110940000002,
0.018402830940000003,
0.01799481994,
0.018223985940000003,
0.01759861894,
0.018958858940000003,
0.01837748394,
0.01904514494,
0.01809492294,
0.018427259940000003,
0.01818821094,
0.01813986894,
0.017615985940000002,
0.01796003594,
0.017505334940000002,
0.017965291940000003,
0.017791317940000002,
0.01812525794,
0.01798888094,
0.017678036940000003,
0.01851067694,
0.01800311694,
0.01808681394,
0.018373394940000003,
0.017636636940000002,
0.01763808194,
0.018445332940000003,
0.018159857940000003,
0.017980174940000003,
0.018537869940000003,
0.01955623394,
0.01860408494,
0.018257304940000003,
0.01800734094,
0.018969050940000003,
0.01744151794,
0.01839679694,
0.01871990494,
0.01770890894,
0.01807889994,
0.018185478940000003,
0.01817902994,
0.01770351694,
0.017856927940000003,
0.018366142940000003,
0.017762881940000003,
0.01861377394,
0.018307835940000003,
0.01844301694,
0.017335730940000002,
0.01826272194,
0.018238106940000002,
0.01845287894,
0.01923389294,
0.019019420940000004,
0.01755005494,
0.01829958194
],
"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 day01/day01-p2.py",
"mean": 0.020615625919999995,
"stddev": 0.0008088849992798855,
"median": 0.02046746494,
"user": 0.017299320000000003,
"system": 0.0031129196,
"min": 0.019567234939999997,
"max": 0.02628018894,
"times": [
0.02120531594,
0.020777152939999998,
0.02165869094,
0.020604701939999998,
0.02084050594,
0.02121598294,
0.02162024094,
0.021570440939999998,
0.02122411594,
0.02059801294,
0.02178862094,
0.02069527294,
0.02011315294,
0.02125525994,
0.02096512494,
0.02085369194,
0.020566496939999998,
0.020334108939999998,
0.020670181939999997,
0.02072439694,
0.02028807694,
0.02055907894,
0.02050522594,
0.02092301294,
0.02069373694,
0.02047648894,
0.019976937939999998,
0.019910852939999998,
0.020397030939999998,
0.020378081939999997,
0.02104977694,
0.02029634894,
0.02018755294,
0.02131716194,
0.019567234939999997,
0.02075919594,
0.01991730294,
0.02038686994,
0.02033121294,
0.01992772394,
0.020304039939999997,
0.01986143994,
0.020572858939999997,
0.020734446939999998,
0.019846204939999997,
0.02002030594,
0.019718745939999997,
0.02024268194,
0.02153054794,
0.02041505394,
0.02017235094,
0.02079594794,
0.01996096494,
0.020180008939999997,
0.02079084694,
0.021043737939999998,
0.019837977939999998,
0.02061569094,
0.02031442194,
0.02030791894,
0.019852781939999998,
0.020351002939999998,
0.020259908939999998,
0.02053684794,
0.02018773594,
0.01992955094,
0.02045844094,
0.01992390594,
0.020803037939999998,
0.02061347694,
0.02014947494,
0.020152006939999998,
0.02034143394,
0.01983471794,
0.020450447939999998,
0.022272646939999998,
0.02044323294,
0.020688650939999997,
0.020061243939999997,
0.020233437939999998,
0.020981132939999998,
0.019957915939999998,
0.02051775194,
0.01970484894,
0.02035442294,
0.019966405939999998,
0.02193963894,
0.02078478494,
0.02628018894,
0.02180391294,
0.020251498939999998,
0.02187088094,
0.020118542939999998,
0.021709151939999997,
0.02086194094,
0.01997328994,
0.020484386939999998,
0.021529263939999998,
0.019873743939999997,
0.02065833294
],
"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": "for run in {1..100}; do target/release/aoc2025 1; done",
"mean": 0.10949902425999998,
"stddev": 0.01303120138107424,
"median": 0.10794122648000001,
"user": 0.0481385,
"system": 0.06004530999999999,
"min": 0.08743557148000002,
"max": 0.14346140548,
"times": [
0.10262904248000002,
0.10309315948000002,
0.08788191948000001,
0.08788880848000001,
0.08988906048000002,
0.08751818448000001,
0.08957111248,
0.09758415848000002,
0.09701446348000001,
0.09691613148000001,
0.09622675148000001,
0.09456499148000001,
0.09579022648000002,
0.09444151848000001,
0.09508792248000002,
0.09606605248000001,
0.09695228048000001,
0.09945660648000001,
0.09628507748000001,
0.09672642548000002,
0.09634512948000001,
0.09588621348000001,
0.09470692948000001,
0.09532162748000002,
0.09455080948000001,
0.09497292148000001,
0.10120339848000001,
0.11154805048000001,
0.11532427548000002,
0.12480157548000002,
0.12592739948,
0.12507496648,
0.12549518748,
0.12522092848,
0.12732470448,
0.12790656448,
0.12489098348000001,
0.13339627348,
0.10624044648000001,
0.10724894148000001,
0.10669420748000001,
0.10763329948000001,
0.10534154348000001,
0.10543322348000002,
0.10665542748000001,
0.10487852848000001,
0.10716879648000001,
0.11600640648000002,
0.11622806648000002,
0.11648707548000001,
0.11719899848000001,
0.11843976248000002,
0.08857608548000001,
0.09061829048000002,
0.08743557148000002,
0.10892493048000002,
0.11079558148000002,
0.11606146848000001,
0.12125704848000002,
0.12159368348000002,
0.11949176648000001,
0.11928547748000001,
0.12190114648000001,
0.12102119648000001,
0.12058027548000001,
0.12061425148000002,
0.12009168948000001,
0.12136069848000001,
0.12952496048,
0.09928884548000001,
0.09773379248000001,
0.09590983548000001,
0.10297853048000001,
0.11318080748000002,
0.11342295148000002,
0.11455993448000001,
0.11295701548000002,
0.11299484748000001,
0.11239145748000001,
0.11219660648000002,
0.11406977448000001,
0.11238566648000001,
0.11289772048000002,
0.11166642748000001,
0.12329825748000002,
0.12529479848,
0.13912101548,
0.14346140548,
0.14263528748,
0.12373552048000001,
0.10561196548000001,
0.10513752748,
0.10701318248000001,
0.10513885148000002,
0.10542516148000002,
0.10548880248000002,
0.10595660348000001,
0.10824915348000001,
0.11516850448000002,
0.12826149748000001
],
"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 1-1.py",
"mean": 0.01843302404,
"stddev": 0.0012657147339510022,
"median": 0.017979195580000003,
"user": 0.015601169999999998,
"system": 0.002655909,
"min": 0.01719525558,
"max": 0.024262817580000005,
"times": [
0.021940215580000005,
0.02037590558,
0.01956901858,
0.01847677558,
0.017818465580000005,
0.017927290580000005,
0.01987165758,
0.017643502580000005,
0.01889718958,
0.017678766580000005,
0.01798546058,
0.01796282558,
0.018096614580000003,
0.019076076580000004,
0.017984125580000003,
0.01791695258,
0.01766349558,
0.02018217858,
0.01855690058,
0.01782171658,
0.018275047580000002,
0.01793372058,
0.018170532580000003,
0.017849274580000005,
0.01762079558,
0.01847150358,
0.017508063580000004,
0.017649895580000005,
0.01746609658,
0.017974265580000003,
0.01829079258,
0.01731760458,
0.01785077358,
0.01721457758,
0.01787336758,
0.018715130580000003,
0.017604400580000006,
0.01719525558,
0.01837595358,
0.019775062580000002,
0.017288543580000003,
0.017996394580000005,
0.017708625580000005,
0.01723078058,
0.01859565758,
0.017730976580000002,
0.017462975580000005,
0.017829121580000003,
0.01851731458,
0.01785272158,
0.01804898958,
0.017888834580000006,
0.01731304058,
0.017909111580000005,
0.018421691580000003,
0.017520087580000003,
0.01780653158,
0.017915070580000005,
0.01786583858,
0.017567218580000002,
0.018018454580000003,
0.01769244358,
0.018978892580000004,
0.01816111358,
0.017368446580000002,
0.017602324580000002,
0.01786462758,
0.01852068958,
0.018079517580000003,
0.01744804658,
0.017847348580000005,
0.01761715958,
0.01768220458,
0.017716536580000004,
0.017590534580000004,
0.01916825858,
0.01837094258,
0.024262817580000005,
0.023162718580000005,
0.02013178158,
0.022817841580000005,
0.019455812580000002,
0.018663137580000003,
0.020078744580000002,
0.018950286580000003,
0.022046223580000003,
0.01906816058,
0.01824326458,
0.01871615058,
0.01788724858,
0.018833006580000006,
0.01850424658,
0.020043292580000004,
0.01800679058,
0.01962254158,
0.017958190580000005,
0.018563434580000003,
0.01756514958,
0.017695261580000003,
0.018251983580000006
],
"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 1-2.py",
"mean": 0.10065511542000002,
"stddev": 0.005070299601528213,
"median": 0.10021386182000001,
"user": 0.09656875,
"system": 0.003348090000000002,
"min": 0.08970616732000002,
"max": 0.12020687432000002,
"times": [
0.09720221832,
0.09865108932000001,
0.09526603432000001,
0.10220708232000002,
0.10600740832000001,
0.09565718732000002,
0.09584613332000001,
0.10399513632000001,
0.10715478232000002,
0.10124971932000001,
0.10037107232000002,
0.10223235032000001,
0.09968424232,
0.09940458732000002,
0.09930831532,
0.09532145232000001,
0.08970616732000002,
0.09986469332000002,
0.09213563732,
0.09521426632,
0.10171789432000002,
0.09781683532000002,
0.10088793532000001,
0.10186061832000001,
0.09871522032,
0.10478594232,
0.09268426532000001,
0.11021149432,
0.10253815832000002,
0.09696197432,
0.09825557732000001,
0.10135564132000001,
0.10723291232000001,
0.09486173832000001,
0.12020687432000002,
0.10346667332000001,
0.09620447132000001,
0.10211980332000001,
0.10263448232000001,
0.09739181032000001,
0.10659001632000001,
0.09343680432000001,
0.10017148632000002,
0.09568633732000001,
0.10377575732000001,
0.10569169432000002,
0.09891529332000001,
0.09706895132000001,
0.10359639532,
0.11909498532000001,
0.10124096632000001,
0.10726747332000001,
0.09666090032,
0.10025623732000001,
0.09513318232000001,
0.10827525632000001,
0.10478741132000001,
0.09365811832000001,
0.09568155632000001,
0.10111659732000002,
0.10849375632000001,
0.10122607432000001,
0.09808621332000002,
0.10768904532000001,
0.09773930432000001,
0.10163057132000002,
0.09868030232000001,
0.10004012732,
0.09432664032000002,
0.09809490532000001,
0.09813455632000001,
0.10013154632000001,
0.10039868432000001,
0.09614563532,
0.09835838332,
0.09961064332000001,
0.10083732132,
0.10392489432000002,
0.10173207032,
0.09681472732000002,
0.09998077132000001,
0.10510356132000001,
0.10299731132,
0.09985206932000001,
0.10440825632000002,
0.10392704632000001,
0.10417230732000002,
0.10073995232,
0.10120393632000001,
0.10234714332000001,
0.09503944032000002,
0.09673561932000001,
0.10741705832000001,
0.11105290632,
0.09754221632000001,
0.10467473532000002,
0.09256150232000002,
0.09705440132000001,
0.10414729132000002,
0.09596329532000002
],
"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": "sander_hs/bin/d01-p1",
"mean": 0.022359646950000003,
"stddev": 0.003947930999644063,
"median": 0.0221566094,
"user": 0.011003309999999999,
"system": 0.0036034243999999997,
"min": 0.011151118400000002,
"max": 0.0418797714,
"times": [
0.021608108400000003,
0.0216550764,
0.0214301634,
0.0217091644,
0.021845091400000002,
0.0218199154,
0.0219022274,
0.0222604954,
0.0221990744,
0.0221290354,
0.022109658400000003,
0.0221543054,
0.0220385414,
0.0221145864,
0.0222324194,
0.0222197784,
0.022081751400000002,
0.0221985664,
0.0221589134,
0.022402793400000003,
0.022002303400000003,
0.022110325400000002,
0.0219013264,
0.022116461400000002,
0.021828275400000003,
0.021764728400000002,
0.0218213174,
0.011151118400000002,
0.021338464400000003,
0.0224858174,
0.04095669340000001,
0.023139116400000003,
0.022919120400000003,
0.0401848994,
0.023492082400000003,
0.0235819404,
0.0233865764,
0.023311378400000003,
0.0237322984,
0.023424249400000003,
0.023000724400000002,
0.0230065454,
0.0218798444,
0.0218653774,
0.021647235400000003,
0.022240412400000003,
0.0224920394,
0.0223583574,
0.0223172124,
0.0220545844,
0.011460039400000002,
0.012014767400000001,
0.011425214400000001,
0.022288648400000003,
0.0214406644,
0.021533019400000002,
0.022723869400000003,
0.0418797714,
0.023123074400000002,
0.022699171400000002,
0.022425212400000002,
0.0225628434,
0.0217416164,
0.021699208400000003,
0.0221595004,
0.022477877400000002,
0.0222780814,
0.0225413564,
0.0223755154,
0.021824677400000003,
0.021797454400000003,
0.021913774400000002,
0.0218400794,
0.022196666400000002,
0.022422626400000003,
0.0221716494,
0.022310612400000002,
0.022924382400000002,
0.023227522400000002,
0.022039313400000003,
0.021584635400000003,
0.0217211544,
0.021672446400000003,
0.0218050724,
0.0217344044,
0.0223603214,
0.0224140354,
0.0225898824,
0.022544186400000003,
0.022495991400000002,
0.022461002400000003,
0.022642661400000003,
0.0216293234,
0.021656978400000002,
0.0217763664,
0.021687655400000002,
0.0218970694,
0.021596916400000003,
0.0222494804,
0.0221464094
],
"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.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@ -0,0 +1,16 @@
backports.tarfile==1.2.0
chardet==5.2.0
fqdn==1.5.1
html5lib==1.1
importlib-metadata==8.0.0
isoduration==20.11.0
jaraco.collections==5.1.0
jsonpointer==3.0.0
notebook==7.4.1
pip-chill==1.0.2
seaborn==0.13.2
tinycss2==1.4.0
toml==0.10.2
tomli==2.0.1
uri-template==1.3.0
webcolors==24.11.1

View File

@ -0,0 +1,7 @@
# Build binaries
ghc -O2 sander_hs/d01p1.hs -o sander_hs/bin/d01-p1
# Benchmark day 1
hyperfine --warmup 5 --export-json data/sander-d01-p1.json --runs 100 \
"sander_hs/bin/d01-p1"

View File

@ -0,0 +1,40 @@
import System.IO
import Control.Monad
main :: IO()
main = do handle <- openFile "../rust/inputs/01.txt" ReadMode
contents <- hGetContents handle
print (doday1_1 contents)
hClose handle
-- Day 1: ...
-- Part One (correct)
doday1_1 :: String -> String
doday1_1 input = show (countZeroRotations (words input) 50)
countZeroRotations :: [String] -> Int -> Int
countZeroRotations [] _ = 0
countZeroRotations (x : xs) pos = countZeroRotations xs (fst (rotateDial x pos)) + snd (rotateDial x pos)
rotateDial :: String -> Int -> (Int, Int)
rotateDial (direction : r) pos
| direction == 'L' && newposl == 0 = (normalizeHundred newposl, 1)
| direction == 'L' = (normalizeHundred newposl, 0)
| direction == 'R' && newposr == 0 = (normalizeHundred newposr, 1)
| direction == 'R' = (normalizeHundred newposr, 0)
where newposl = normalizeHundred (pos - (read r))
newposr = normalizeHundred (pos + (read r))
normalizeHundred :: Int -> Int
normalizeHundred x
| x >= 0 && x < 100 = x
| x >= 100 = normalizeHundred (x - 100)
| x < 0 = normalizeHundred (x + 100)
| True = x
-- Part Two
doday1_2 :: String -> String
doday1_2 input = undefined

30
bram/benchmarks/shell.nix Normal file
View File

@ -0,0 +1,30 @@
let
pkgs = import <nixpkgs> {};
in pkgs.mkShell {
packages = with pkgs; [
# Benchmarking tool
hyperfine
# Haskell
haskell.compiler.native-bignum.ghc967
# Jupyter notebook
(python312.withPackages
(py-pkgs: with py-pkgs; [
matplotlib
notebook
pandas
pip-chill
seaborn
])
)
];
# Rust installation
nativeBuildInputs = with pkgs; [ rustc cargo gcc rustfmt clippy valgrind ];
# Certain Rust tools won't work without this
# This can also be fixed by using oxalica/rust-overlay and specifying the rust-src extension
# See https://discourse.nixos.org/t/rust-src-not-found-and-other-misadventures-of-developing-rust-on-nixos/11570/3?u=samuela. for more details.
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
}

View File

@ -0,0 +1,201 @@
2233643232222242333443433223122333324326451323323334325223136631334332233233323164354342233332238233
6436547659356357277564683346658554864789866767856546426667566576537557576764753366663247799566575359
4322212422212222222222112222221252322222222222121152214312222222226122122421262632221222352222223522
5242873574376258254526262841222235756126125363535226724625252231422222223232432416114933476433226425
4423241233122222212222152223222321224343432221222131223143222222223442622361254132221212223321223232
2354443335444444444445473233436443443447434343453464372444444744444341435444543443433645644446664444
7344773375355374532433311243433365663564579278356438583444355566467535626553263862265655437577558445
2422122121212324322412122634143132116824441421223222862232324232233322227221224221222232422452322422
2335425524341553453213523155345249534445348244223423324254265524132552444254422523422425353142334556
2543542334354463443444631655434665743432434343442354554443244445263434575354472655455354443554334453
2533222231331423136323422331324323122212222133234123324923235534153325322253223223121312212332233222
3655636344614544753471372637363622461657323523555373676516477617243136625537745875577456765251534745
8347857486272332654345885359345864556245456476353536374444758537485854624467575625455471966355365444
2333131222324323323333122331322333223232233313232332423233313334321321324232231322333313332323233322
4333455333232133222434323424423223782622224423233533223343333237344243134333437453254322633363332442
3333224546432265536343345623343413494323264462333222332725333245323343134323244336443544223233233344
1122222222422322432314212522412222221222221222213224222532253232222211212243222222112122242232335222
6223222222211527224244221412234422422713221226223222321153222234233432222213222222222222222324231636
5522284428622511162523222215246221521122222226162118422222222122212222225432222224262224422471367526
5956484444745474342547425434594374468434864864145434543435444445445435447847779785545443385653654957
3142333733311646312333123413312243223323322322513332472235234224324411362463132422246321332342334253
2492222222662312432222234253224154223124222422222213353722442234192272247469222421222262223267156265
1222322226313332322222322222252325331322122133223322232222712222224726531252321222222231322222222233
4438912132222624231242322622336222122622235321223232221222212122524232224232242223126113262212212435
4342543122243322234244522425514322434334515225622212522435254747435834212524224434345847214233232221
2232662535536423636216213652233222333323333326232362322345211258324623265442343221333714253323275637
2692334323322554444433246235632624244563226221655324344313452376684265724434633442434233553662233643
1644224326534722127241464425124252623243373421327743244224241335526234247333375133245132323342647346
5333657533435533437765632361628578858239468476298973236397242266676766654544552648636554686924674746
4251343354552554445476666443753334477733455252244352372543524364954246663435527633554214534575345543
3245444253442524962129783345453352426254163846525128886263548552344445395534373553663544462243475363
2142532422249222122122222121162472244223312421312253332722222114213222352432221242221233181232122212
4566465546696559368565756646438955545369947544855754656465452555756544447765644457465366557485337369
1772653222555582242247246232214292222697233222223253514255232252129642112322335241212183231264525284
4354354427322426542444547537346731353311444756444523378323634345432344556435433536444746445434454453
5344542553344445244734444454543444343844354445344455544437343413454472243534445445435545543335434544
2421234244222324252243122112531222432451151212536641122423232254323625642217243224625513637522242233
2444236443231233244646213453222422433135223422213222112323142221124322223132322364143222422234525135
3993952352239334636476372777272353823836333556663343425385311323219418661163732333739633435335233629
2335132452334122223322212232323222332121214232343232321253615232234232222225124143231423232421221232
3435253533345115535125331555355212454321233141243323222231511511242334253123412222244355444111336789
4342262562424446414642344324642513444741415543524724444347445424742344243227544243834261383344344433
5133269339551412322324214425133339363433753643223332253433334733423351353332323252563825324213546533
3365372336245325375435335434332645526446285234343523632282522323636232643244678477432531362385446246
2311131324212395342286212542325322246532472361652435616622122663643522122343832326532338222232323482
7765353451358575733572283573547384566323256675564262642584334376524365537964746444124713224735546774
2252222525225522412122213464272135235332236223312272922282292361721421642435252222222226223782322215
2134223233222221422122222223312222321222423333322222233223223232122322211216211222321222223242222422
2222361132122134212316842523222722221729212242142646822267221232222222222412222222522222242753222222
5337864557478543434125566533466435547454453457543754463395635497321323245554355354848544555244335554
4466625524532724322343146236829413367515473225463633637657254355393224314422246746538323136326741268
2322233123334342233531132214322222423222332332324712223135133223235235532233233332322352216243433223
3633623322235342316346231131633361331265333443339233365455623337353332167234337236515462224252333216
3322584324332533632225363333332331626133332232223132322321336323322334213633233333215232333442313275
5965751122343223845246255553658564621769664976957663344222229522752322289731722915285462282698823463
3121123533222322223221263122523242222123232221232342322162223241233222314224211222222122122322232212
6122331319122223262333221232321143613412232222221213242132321221322221332342352322122226512222222633
5145245555235222232228435425532224121513422242326222356224253225455252412222754222322432125224161442
3132322122223332322332242224222322222422352533113232233223232223222341222123253242213213224323354225
3252413233224241123451142223232242212442241222231545322234225222422473143343222322424222122252122416
1222222432232632232221222223222122521241321222251212132222211232332222334222222232224222322222222133
2133325423225322332222532333232222323233222322122152432122332224212222222222212323324323322362632221
4122341242242411343233341124424221223432443244144143434244411231333334322314223334222434334414256789
2222212542623221122371215317524472552543532242222229542515225421552216216324337665122323271821561222
2122122122122422123242223132212211232222223222228423241243212222232242216422232232113122122222232222
2342451233212332332223232222123322212234372232433123322242422233233221221324231233221221232222235312
1531224333222562318222324631131222342272182322522822182242335222241223334222527222212244253473221323
2222233222142234223233121222223122242221213223222122332242431122213321122214222212223322224222223312
2222222143243227332452232222322322321323613266223112234422442212224233243242223133522611232111122321
5654553447313533554553893854763333467444552579533944455663535653524659436665547645355435546543554545
5323331522211233252524233313212132234222532343133332653523335426323323143321221322323323221347322323
3344255554553462322384556525546538353335583545124321555537334342254324532523646534635433532353543335
2252335254447422332431226227992713322234315316472133442221225414241542213654242426442132142182572344
3135523223226233323223323223222544253222122262342343232237222425282315212232123222235333112312222334
3354773326663365346493365244732433363452542643435334753354577776335434754556592544964263743422332443
6371439222222352424162472287212322327622532242273512222352621682699762212223226214132243222323527222
2232543232222452352224332423252323532333242233144332224232233325233442123233222442332344242445234243
6425615474554454141541665641252716724411315412715646331276275654347342167232742714674637136141217389
3235333323334334433422362433341233323333231333336463133333453437363325442333342333823233363633333354
5765262746346263664544526674676762456349723566665876664674156663555573556676764444715554476437677855
7423434333422334442444334422343286432323333344344314233133333443444333838532343434543341233343232733
6774788365875695878887443545568759778677247747655763848548555778646627725586786843876788675548758494
3262313215125212725325312211423222332227433222263225122322254423222211222422352233312213443215423525
6142243652443244444342244442113325153442421335264515232174224223431316224224433264315222264244474425
2921833253133742442324622132642228232344243922221222431224543231122332332233333123362234243552323522
5632565666566658566466565564426236675643353576665434456559645576553857764724552526336855216775546576
2532452536565234455556555433545333343535235259355533573737535333495454353444323553254555558327634454
5548929366483365659354448563354373455759474784978453866356866476356667554667454666687754395646666584
2422224232218244232132234324422124322122422432233246415332224232332414212225332241243325223322222222
3758934793272332176257536845332333423543533433543322226223463523347666464677433843442824654415933924
2622232121212222232322152424125221342152122221224222323442222231221231265222424444243222225322221222
6214422421342323434331423232234143232134222323441334231133223132222426213232335122424533433312424333
5495352464253923643432324472475257423635544644337693443224359353932343696565533473655334633335357234
7254749566545484267477472424253562668987384296476363553384653423843774734634364663792242324756555646
6226324333333271442443546421325232432323192149222232363654233652232253322232543523855788643345523533
6423316551511466142352352513435356146435255444345656413213453213333153116125465222652164154334412789
3233343444252424634655344331632462565545324335341334523524342535241225553354334625422632545362561363
3445525556368253862333435337455253455524557517455232345255743265518361673494731765233544323823734449
8544272422454343423222253523841223262532426642832273222113352334442513324141234434252431222216421154
5423334354644265263636536355524642453634246642522263635654356321443365454125632234324233624247276342
6443545413135523533265443323245434225234223442514335322555552333234542252323354441535625432213233475
3212212222223312122122125221321232213221322313122221312222226222222122212222222922221223212132141212
2323212122324611722242222244224112222243222123241262221222362413421211233222242222215222124222122331
5844366354463476656352455342626163223651573323322732274227653444734256235242233221366322344236655364
2625454454614434442613618224132466334432732446343621534141835624243221346614444345314364443148234344
2323222223223124321322321223214122333222332222231313222222332322222522333223222122132323212343223223
4437368344416381611321431224542447234422632416425742323247454382441741433122653324364923229242444543
1246633747466243525472445465264464613362434426572366643424314563444534564662442453243348442543252552
8455213554255167364635127532563534225444445625337655356663242455242553536364567566362637563621552464
1145243234422322531234121131315342152533253745423235234129642243232433334524273522215353252222256345
2222221322232522222222232222223222212222223212222232222112321222123213222222242121522231322322222222
5554324763412143342413244121235412334563414442244613543522434445264434234433442544443434242225336524
3212234222234342422134323321353344221222241463622421223322332224422435432352244231322324233321242222
1738535622754134632333123483712322334123243222775212333324326533722431671361323312322346241332334322
4351132523543724323443552656312222233223234323221255492443514427243424322442435353343365537374457525
2226222122222222222211222321222222362222222222262221222222222462222242422221222112213252923212222227
7372265262132122222222222282647132453212233322331232223212732224333228225333323211212536423333531243
3342577332235352233233553852633532263644351255533142324433446226235457211213535744631435423223364363
8446255244282932322534869773258925347844614356985425432837381986388785453532534245572534443192852357
5446735236335373623324345623337331834844472537246434774964444227448844322344333544544434382344464148
4433323344453244323434533223334334444433433643133631233655333413335732264332842324635343324544539433
6344376432398243372333532336643528844236533248338383473645366575356475384433935577645374443832252963
3443222635222221244334227234322246222342227224235242323213273234134421523235225245425122222255224231
6585657577798869776763766747566877567766997677734495477637554466647747676466367736757977637777676777
3242552333334223333252225333433565333333465343535354235233123752242314432223435333332233333332223332
1311222262211312324225221221345121353311223322212222241343223322112224651422143221323251213224222225
5533566445555425555535555545655564353354655435445566346633555555464665566547564434755465554654365665
3463363433672383135556336377441633635538123755433353487535473513268444423364361656537543324433363331
2222122334223322241131242133321225242732213242326212422232444422322212222223342231223222322222422213
4323633242332312332424232178525522242552333523216333423225215442333672335222322723212232753241221533
4362565458455443433534444665335234724445746564455242246332242464545442435623423325344343664843444243
2223437712828555541728813515663367733828286734326188656173257638346432837355155675314858434277276319
5244262352623221152324113352242726453823552433244642443115222322322662622123452436542542126162944562
2222362523222242322324333353323221232222533231223413323541411332323322544333232433153322333233223142
2225312222212215222122212322213222513122221422323222322225262221222251222457222112222121342121222221
4313232231424332229233454343224319396724123323633382235223632236322391443232222332212432283863439233
5213575451225235425253533432213743534342624252124435242432121345254352522422122212553341253217252322
2123412112522432522412192122226522121425425222252222522512262432222222411232122222423341231351232221
5465625548366424522551965584434936726545472565217598582254364534384215551343672449253467655554836446
7254422422222617225423523253332238633333432123322237324623122462125452782322233252232462154221236133
6535353554552342214454325582546583245579544353448348251572751295756482557556245336852375322477534475
4322124613433135333247343244442342123263246432131544439324486672223437344234314333231434329452334422
3222122222211221222442221522222323121122254222222212221122222222212132223211142223221222122232253223
4522264542561523248146564185215223352222363522622331425472532241114233344524356242234315554712254611
4524553354655655655852774652636663566555536557376256434754354524655756453536565466492456544475546375
6482342921224824333643274834413223286723233143344312632422114943523238322122443642964332282223862242
2222532222225126242562235312251241241152363142662511122221241252422235424523144132221224242525432316
3352233122122222414623322422421412265422222322631132532211362245214223424432222632322122452236232543
7435435245443454483642323432454553456537424534753454323445333535524536533132553244725534224634223674
4442455534524835435555455546253515474453446464546545554444443534453544443464344544455454444445545656
6318372235932344212322623432143332348233334233234531434374327935349323133422333672232723333333333313
2343437112323223553423322434332234373285822222438334742444737123322352633236431422342337553563236343
2534525223332122254212422543221212222333444234231612225123231222134222224211232431442153233222232235
3311333353223232533542243332322443233333433334433333333334343333233225332233334323333332233323334534
3728642494543682323613638224245843442324642214465451312451322235317994852247254439532312342435223415
2644444442446656433255324244844744224332444644642423633224344444334435346443263334422284244442354422
2132343337743333341331172224332353222832422333133333324323434332423323223323333123532233221521332232
6456746544533347353533424453434256445454442444545332474441436424325427632384444467424543463243246273
3133424321432223332224512124224222232131232222432232433224233324222323231122133222444342422223422412
2951222223232342212324221372233422121222222122428412742122222272113231225115272231252232221122231342
4332522234422363462322222143321322323545222323433222352435311251238232125232422442222133116432133222
7666998669668693896756755965999793569795865899869698558598997759886859928589579967584996689695478789
4352363453212525423622255562341442344215444134321422542354722245343422441244464243637481135554112362
3223443344545244343434584554333453154433434434333249442265443244333635455338332244343243311134334424
1665322162231323425324323123442341125222233315531323536111322442242235242132414112244264232443422245
2414221222221172231122222143244322162212222222425232121223222222221222422345212226312222112112221232
3331333314633233122533233233233112324313222231331243321234122333341411343323323432121313333225221232
2642724252231252242432324542254325124442563345455242145355324151614235225515342253523532421213493425
6315423423623323244234343366465111333233473411272233343328223323662414442233633141132225735345273323
2255222422222341222222221221242522222412222122121222222221222225322225221312112222122422222222221252
3221262222222452233122222424222222221221233427232242322221283223253322122222222222221211222222222322
3563473466663465624422525832655214646265347424423434534754575561344661544144721234545452426624325665
1512522452333543222325524385269535432435333245472553438445343544134325483212359524535452434233544546
1242352442411351533231323433123333232332131522241133232223323312221332252133231231222521342332233113
6796977884635885678886386887784686985966565558559785568975267889586689776858777746657576899885687867
1322221211222232222222212224341222212122652423212122232222221622222212122222264522211212112222222222
2221122242132222242321653225213222212212123122122225216212241422222121335224252128222312122223152213
2222485454314145422676223532428253544275212444246273219543235423266271388223486621383423434123322786
9264342243354532322432433325652333233452313535423525423336263384434513334133343152333512233333211423
2221254122222222483253222232224232221212127215222224142222112222222222312552242222122224121422222211
1234422452224434224462441231223422424234232233163423323463242243214153522224424343443144243233321226
2322212322222232222122222111221213222232122222212222222212222322321212111322222122221222222212221221
3434526563345631541253456353554355344534635445555335344434585646443364555465443732452735555413335455
3225312137123114121262224262133222252322222211222221322324232222112222621222224422222232222221266238
2353522543223422534146562225414223172345423224513313523223255542242224543225213372456442522442223274
2321822523345672525222333345331141642241339237232233346584343212323556147252622534732253132335723124
2221142243241323222232423422323251235242422122522224222322222325214214222222234332641212512222222223
5352353234444335353333325633455343325334323243442544543453525334742134535534164234322442365546552443
1644535454544465443444444444356555544434446443634464664335484454462433434354444442444466442444522245
6433454454447444425444475352634433345446225436132754337645216743354253676545324347755544565443915533
3467493473794344524434814455434343541545634344354934325134523344486353664347445446466468352473724335
6583456635588454567555367246548474858674467585559584465654664563665845468923825636652445446833546865
5444533574534446655337755343315552455447755452563434858445835538545235556545555373594853555475534542
3441235133213337324673253262369232322322523734393339321333332333338374353323483332652333273343333334
2422443223431842223321234271323322427434181322342241645342244245114331332453823332343424413141233222
3324243325325223334126334234442422148382225223733442252241413434444155241324232233814134662324642534
4426433352444223343443233364226332215123531534353433343449744443257223333742332354436544443343235466
1311262322731223323222364222211222212331291223331233416323222221212322331423211242312141133222213123
2231221213222221212231221334133642822242221322242121224231222213322222222222223213122225213222251122
2222462325135343335552659427182617224656226146173226235225282512237335226552631126273541364136347217

View File

@ -30,14 +30,6 @@ pub fn answer(text : String) ->( u16, u16 ) {
( clicks, 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> {
if s.len() < 2 {
return None;

View File

@ -0,0 +1,56 @@
use crate::utils;
pub fn answer(text : String) -> ( u64, u64 ) {
text.as_str()
.split_whitespace()
.map(|s|
( BatteryBank::from(s, 2), BatteryBank::from(s, 12) )
)
.fold((0, 0), |(t1, t2), (b1, b2)| (t1 + b1, t2 + b2))
}
struct BatteryBank {
digits : Vec<u8>,
size : usize,
}
impl BatteryBank {
fn add_battery(&mut self, b : u8, min_pos : usize) {
for i in min_pos..self.size {
match self.digits.get(i) {
Some(x) =>
if b > *x {
self.digits.truncate(i);
self.digits.push(b);
return;
},
None => {
self.digits.push(b);
return;
},
}
}
}
fn from(s : &str, size : usize) -> u64 {
let mut bank = BatteryBank { digits : Vec::new(), size : size };
let l : usize = s.len();
for (i, n) in s.chars().filter_map(utils::char_to_u8).enumerate() {
let offset : usize = l - i;
bank.add_battery(n, if offset > size { 0 } else { size - offset });
}
bank.measure_joltage().unwrap()
}
fn measure_joltage(&self) -> Option<u64> {
let mut joltage : u64 = 0;
for i in 0..self.size {
let n : &u8 = self.digits.get(i)?;
joltage = 10 * joltage + (*n as u64);
}
Some(joltage)
}
}

View File

@ -1,6 +1,6 @@
mod day_01;
mod day_02;
// mod day_03;
mod day_03;
// mod day_04;
// mod day_05;
// mod day_06;
@ -15,7 +15,7 @@ use std::time::Duration;
use crate::utils::read_from_file;
use crate::utils::diagnostics;
type DailyOutput = ( u128, u128, Duration );
pub type DailyOutput = ( u128, u128, Duration );
pub use crate::utils::diagnostics::AdventOfCode;
@ -33,12 +33,12 @@ pub fn day_02() -> DailyOutput {
( p1 as u128, p2 as u128, d )
}
// pub fn day_03() -> DailyOutput {
// let s : String = read_from_file("inputs/03.txt");
// let (p1, p2, d) = diagnostics::benchmark(s, day_03::answer);
pub fn day_03() -> DailyOutput {
let s : String = read_from_file("inputs/03.txt");
let (p1, p2, d) = diagnostics::benchmark(s, day_03::answer);
// ( p1 as u128, p2 as u128, d )
// }
( p1 as u128, p2 as u128, d )
}
// pub fn day_04() -> DailyOutput {
// let s : String = read_from_file("inputs/04.txt");

View File

@ -1,9 +1,36 @@
fn main() {
let args: Vec<String> = std::env::args().collect();
if args.len() > 1 {
let day : Option<u8> = args[1].parse().ok();
match day {
Some(1) => run_day(aoc2025::day_01),
// Some(2) => run_day(aoc2025::day_02),
// Some(3) => run_day(aoc2025::day_03),
// Some(4) => run_day(aoc2025::day_04),
// Some(5) => run_day(aoc2025::day_05),
// Some(6) => run_day(aoc2025::day_06),
// Some(7) => run_day(aoc2025::day_07),
// Some(8) => run_day(aoc2025::day_08),
// Some(9) => run_day(aoc2025::day_09),
// Some(10) => run_day(aoc2025::day_10),
// Some(11) => run_day(aoc2025::day_11),
// Some(12) => run_day(aoc2025::day_12),
Some(_) => run_all_days(),
None => run_all_days(),
}
} else {
run_all_days();
}
}
fn run_all_days() {
let mut aoc = aoc2025::AdventOfCode::new();
aoc.insert(1, aoc2025::day_01());
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(5, aoc2025::day_05());
// aoc.insert(6, aoc2025::day_06());
@ -16,3 +43,10 @@ fn main() {
aoc.show_diagnostics();
}
fn run_day(day : fn() -> aoc2025::DailyOutput) {
let (p1, p2, _) = day();
println!("Part 1: {}", p1);
println!("Part 2: {}", p2);
}

View File

@ -2,6 +2,10 @@ use std::fs;
pub mod diagnostics;
pub fn char_to_u8(s : char) -> Option<u8> {
s.to_string().parse::<u8>().ok()
}
// pub fn char_to_u64(s : char) -> Option<u64> {
// s.to_string().parse::<u64>().ok()
// }

22
brechtje/1/1-1.py Normal file
View File

@ -0,0 +1,22 @@
input = open("input.txt", "r").read().splitlines()
pos = 50
password = 0
for line in input:
if line.startswith('L'):
pos -= int(line[1:])
elif line.startswith('R'):
pos += int(line[1:])
# keep subtracting or adding 100 until position is between 0 and 99
while pos < 0 or pos > 99:
if pos < 0:
pos += 100
elif pos > 99:
pos -= 100
if pos == 0:
password += 1
print(password)

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

@ -0,0 +1,21 @@
input = open("input.txt", "r").read().splitlines()
pos = 50
password = 0
for line in input:
if line.startswith('L'):
for _ in range(int(line[1:])):
pos -= 1
if pos == -1:
pos = 99
elif pos == 0:
password += 1
elif line.startswith('R'):
for _ in range(int(line[1:])):
pos += 1
if pos == 100:
pos = 0
password += 1
print(password)

51
sander/AoC 2025 Normal file
View File

@ -0,0 +1,51 @@
-- AOC 2025 - Sander
-- so for those wondering about how I run this Haskell code, here's the setup:
-- 1) install GHCup as instructed from https://www.haskell.org/ghcup/
-- 2) save this haskell file and your AOC input file in some directory on your computer
-- 3) rewrite the "main" function with the location of your AOC input file
-- 4) rewrite "print contents" in the "main" function to use the function(s) you've made to process the input file ("contents") from that day correctly
-- 5) run Command Prompt, go to the directory of your files (with "cd" command) and run the command "ghci AOC2025.hs"
-- 6) run command "main"
-- 7) if your functions are correct, you'll get the correct answer!
import System.IO
import Control.Monad
main :: IO()
main = do handle <- openFile "C:/Users/[your directory here]/d1.txt" ReadMode
contents <- hGetContents handle
print (doday1_1 contents)
hClose handle
-- Day 1: ...
-- Part One (correct)
doday1_1 :: String -> String
doday1_1 input = show (countZeroRotations (words input) 50)
countZeroRotations :: [String] -> Int -> Int
countZeroRotations [] _ = 0
countZeroRotations (x : xs) pos = countZeroRotations xs (fst (rotateDial x pos)) + snd (rotateDial x pos)
rotateDial :: String -> Int -> (Int, Int)
rotateDial (direction : r) pos
| direction == 'L' && newposl == 0 = (normalizeHundred newposl, 1)
| direction == 'L' = (normalizeHundred newposl, 0)
| direction == 'R' && newposr == 0 = (normalizeHundred newposr, 1)
| direction == 'R' = (normalizeHundred newposr, 0)
where newposl = normalizeHundred (pos - (read r))
newposr = normalizeHundred (pos + (read r))
normalizeHundred :: Int -> Int
normalizeHundred x
| x >= 0 && x < 100 = x
| x >= 100 = normalizeHundred (x - 100)
| x < 0 = normalizeHundred (x + 100)
| True = x
-- Part Two
doday1_2 :: String -> String
doday1_2 input = undefined