Compare commits

...

18 Commits

21 changed files with 1424 additions and 321 deletions

2
.gitignore vendored
View File

@ -270,6 +270,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.

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.

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

@ -2,114 +2,114 @@
"results": [
{
"command": "python day01/day01-p1.py",
"mean": 0.03822894034999998,
"stddev": 0.012144075223691013,
"median": 0.0384504487,
"user": 0.03276039999999998,
"system": 0.004759478399999999,
"min": 0.023593248699999993,
"max": 0.09378562770000001,
"mean": 0.018280616970000003,
"stddev": 0.0006054695984127279,
"median": 0.018186844940000002,
"user": 0.01483600999999999,
"system": 0.0033221896000000008,
"min": 0.017335730940000002,
"max": 0.020703820940000003,
"times": [
0.0258334727,
0.026854287699999993,
0.0399822297,
0.09378562770000001,
0.035683990699999994,
0.028417045699999997,
0.026040642699999998,
0.0287597727,
0.0379906227,
0.040150946699999995,
0.0524629827,
0.052146840699999995,
0.058593723699999996,
0.056963051699999996,
0.05729004569999999,
0.05239131169999999,
0.030558795699999995,
0.057367665699999994,
0.0552966457,
0.0579215237,
0.05618647969999999,
0.051038109699999994,
0.026448008699999997,
0.027654906699999995,
0.048447536699999995,
0.046660147699999995,
0.0345386817,
0.027381352699999993,
0.0271584057,
0.027664060699999993,
0.026757941699999996,
0.027202629699999994,
0.0272295147,
0.027980929699999997,
0.0263920047,
0.027310674699999996,
0.0362795987,
0.045494989699999995,
0.0482373307,
0.0508878977,
0.0515023517,
0.0534676567,
0.052217589700000004,
0.041405759699999996,
0.028495394699999996,
0.041062544699999995,
0.0417715817,
0.0460366847,
0.0438757577,
0.0454951917,
0.0422026197,
0.0418745007,
0.029570451699999993,
0.0247783267,
0.0403118517,
0.047741050699999996,
0.048363022699999994,
0.0467327777,
0.043327284699999996,
0.0455912847,
0.031468127699999994,
0.028135951699999995,
0.0463591507,
0.043426738699999995,
0.037877277699999996,
0.024560285699999997,
0.024734791699999994,
0.0273053027,
0.026828248699999994,
0.036824954699999995,
0.045858032699999995,
0.043353192699999994,
0.0361220387,
0.0419495127,
0.0487565467,
0.0473831137,
0.0480600207,
0.043068205699999994,
0.0463273517,
0.0442373607,
0.0466131987,
0.0389102747,
0.0393067207,
0.0341753167,
0.026344393699999996,
0.024751101699999993,
0.024112212699999996,
0.024425316699999998,
0.024191128699999995,
0.024199224699999994,
0.0248749707,
0.023593248699999993,
0.023872050699999994,
0.023954621699999998,
0.025759817699999993,
0.024675213699999997,
0.025321191699999995,
0.025912937699999992,
0.027629769699999994,
0.030369005699999993
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,

View File

@ -2,114 +2,114 @@
"results": [
{
"command": "python day01/day01-p2.py",
"mean": 0.04541145110999999,
"stddev": 0.0061659276665782916,
"median": 0.04632733356,
"user": 0.03825545999999999,
"system": 0.0061213699999999975,
"min": 0.03218924256,
"max": 0.057393948560000005,
"mean": 0.020615625919999995,
"stddev": 0.0008088849992798855,
"median": 0.02046746494,
"user": 0.017299320000000003,
"system": 0.0031129196,
"min": 0.019567234939999997,
"max": 0.02628018894,
"times": [
0.04858690756,
0.04062161756,
0.047315361560000005,
0.04205326656,
0.040117793560000004,
0.052948674560000006,
0.05041541956000001,
0.05085754556000001,
0.03410045356000001,
0.033686752560000005,
0.033739053559999996,
0.033689966560000006,
0.03232615456,
0.03523449256,
0.05724295456,
0.05148632056000001,
0.04564088256,
0.04519933356,
0.044088846560000006,
0.04710066156000001,
0.046946055560000005,
0.04893831656,
0.04654469456,
0.04531594656,
0.043697287560000006,
0.04327408856000001,
0.03877720456,
0.04164936056,
0.05022757956,
0.053948838560000004,
0.057393948560000005,
0.05522872356,
0.05110258656000001,
0.05359581356,
0.04724179256000001,
0.04816274556,
0.04592650756000001,
0.04656867356000001,
0.04949912956000001,
0.04514734156,
0.03570722556,
0.04281620456,
0.04206231556000001,
0.033078940560000006,
0.03463973856000001,
0.03972590256,
0.05148204856000001,
0.04829295956,
0.03621049756,
0.033537381559999996,
0.03721896556,
0.05201895256,
0.049742014560000006,
0.04776633956000001,
0.04976611056000001,
0.04418950056,
0.04390970756,
0.04625697156,
0.04728216356000001,
0.049102620560000004,
0.04978503756000001,
0.04476852456000001,
0.04562532056,
0.04424657856,
0.05185844256000001,
0.05180182256,
0.046976191560000005,
0.05024639056000001,
0.04959097156,
0.05101904656,
0.03461228656,
0.03461387356000001,
0.03671324256,
0.04420345456000001,
0.04696286656,
0.055995720560000004,
0.05061502856,
0.05062734456000001,
0.046681447560000006,
0.04721871356,
0.04572565456000001,
0.04501869756,
0.04575281456000001,
0.04932772656000001,
0.05343822956000001,
0.052028300560000004,
0.04766060456,
0.038578869560000006,
0.03218924256,
0.03734468156000001,
0.04384029256000001,
0.050929902560000004,
0.05281846956,
0.04639769556000001,
0.04429052956,
0.04606373456,
0.048083003560000004,
0.045911987560000006,
0.04543999556,
0.04569671756
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,

View File

@ -2,114 +2,114 @@
"results": [
{
"command": "for run in {1..100}; do target/release/aoc2025 1; done",
"mean": 0.3209171330600001,
"stddev": 0.06912370514464004,
"median": 0.31733743842,
"user": 0.12774712000000002,
"system": 0.18811515,
"min": 0.18901236892,
"max": 0.5454262219200001,
"mean": 0.10949902425999998,
"stddev": 0.01303120138107424,
"median": 0.10794122648000001,
"user": 0.0481385,
"system": 0.06004530999999999,
"min": 0.08743557148000002,
"max": 0.14346140548,
"times": [
0.32901505492,
0.35589986292000003,
0.35293158192,
0.36846902592,
0.38234202092,
0.30366900492,
0.29018771692,
0.33612383892000003,
0.32239208392,
0.32289456692,
0.28245230292,
0.26871287792,
0.31043925992,
0.33495310492,
0.32918007292,
0.34974822092,
0.37755511792,
0.36699618592,
0.37780061692,
0.38380039792,
0.38373057992,
0.45611059692,
0.38467784292,
0.38463839292,
0.39507502192,
0.38982799992,
0.39220254592000003,
0.38981040992,
0.39322252992,
0.39439366492,
0.38911047592000003,
0.40424637492,
0.40340111592,
0.40765913792,
0.40841903692000003,
0.39719493192,
0.5454262219200001,
0.48013536792,
0.38111417392,
0.35035591392,
0.30254926192,
0.30795329892,
0.24643972592000002,
0.35967777992,
0.18901236892,
0.21599748091999998,
0.20967083992000002,
0.25930284292,
0.24317482392,
0.30930459692,
0.31939877792,
0.27999646792,
0.25791276992,
0.23326737192000002,
0.28325422992,
0.26893403592,
0.27285110192,
0.42320354692,
0.37206708992,
0.39127948892000003,
0.30741866992,
0.32723120392,
0.26509262392,
0.31527609892,
0.32005553492,
0.19529146892,
0.25337454192,
0.25479495492,
0.28464836992,
0.28461546792,
0.29561398892,
0.24718056092000001,
0.26281247592,
0.27454682192,
0.26249891392,
0.29358589892,
0.27614823592,
0.43836924992000004,
0.23460257892000003,
0.21493214292,
0.19987172792000002,
0.27299085992,
0.19212104691999998,
0.34766739992,
0.40541196492000003,
0.40074627692000003,
0.37993838792,
0.27619252392,
0.32962238392,
0.29411795592,
0.23638225192,
0.26090372492,
0.25797784692,
0.28363530592,
0.25150928992,
0.32068586392,
0.36486215392,
0.26354788392,
0.27554843892,
0.24832705991999998
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,

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

View File

@ -5,11 +5,17 @@ in pkgs.mkShell {
# Benchmarking tool
hyperfine
# Haskell
haskell.compiler.native-bignum.ghc967
# Jupyter notebook
(python312.withPackages
(py-pkgs: with py-pkgs; [
matplotlib
notebook
pandas
pip-chill
seaborn
])
)
];

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