Compare commits
15 Commits
65efdbd0bd
...
9d486ddccf
| Author | SHA1 | Date |
|---|---|---|
|
|
9d486ddccf | |
|
|
ba2815f1ff | |
|
|
84fe03a625 | |
|
|
abe70e2c25 | |
|
|
32242a43b9 | |
|
|
94e87bdae1 | |
|
|
561edcc1a5 | |
|
|
4e84f8a876 | |
|
|
94201f6868 | |
|
|
3be30b2a14 | |
|
|
bd8a50df82 | |
|
|
3faee72c5d | |
|
|
4ae1fea299 | |
|
|
0fd6e45b5e | |
|
|
203ed61e24 |
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
import re
|
||||
|
||||
class ExitFors(Exception):
|
||||
pass
|
||||
|
||||
def get_battery(bank, max_jolt=9):
|
||||
for max in range(max_jolt,0,-1):
|
||||
for candidate in range(0, len(bank)):
|
||||
if int(bank[candidate]) == max:
|
||||
return candidate
|
||||
|
||||
def get_joltage(bank):
|
||||
|
||||
joltage = [" "] * len(bank)
|
||||
|
||||
# Get first battery
|
||||
jolt_1 = get_battery(bank)
|
||||
|
||||
# Second battery is after the first, unless it was the last battery
|
||||
if jolt_1 == len(bank) -1:
|
||||
# Get battery from bank ...upto/before jolt_1
|
||||
jolt_2 = get_battery(bank[:jolt_1])
|
||||
else:
|
||||
# Get battery from bank ...after jolt_1
|
||||
jolt_2 = get_battery(bank[jolt_1+1:]) + jolt_1 + 1
|
||||
|
||||
|
||||
|
||||
joltage[jolt_1] = bank[jolt_1]
|
||||
joltage[jolt_2] = bank[jolt_2]
|
||||
|
||||
joltage_str = "".join(joltage)
|
||||
joltage_str = re.sub(" ", "", joltage_str)
|
||||
|
||||
return int(joltage_str)
|
||||
|
||||
|
||||
|
||||
def read_input(filename):
|
||||
banks = []
|
||||
for bank in open(filename).read().splitlines():
|
||||
banks.append(bank)
|
||||
return banks
|
||||
|
||||
|
||||
# filename = "day03/example_input" # 357
|
||||
filename = "day03/input" # 17092
|
||||
banks = read_input(filename)
|
||||
|
||||
|
||||
total_joltage = 0
|
||||
for bank in banks:
|
||||
total_joltage += get_joltage(bank)
|
||||
|
||||
|
||||
print(f"Total joltage: {total_joltage}")
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
import re
|
||||
|
||||
def set_battery(bank, joltage, start_pos, end_pos, batteries=2):
|
||||
|
||||
if batteries == 0:
|
||||
return 0
|
||||
|
||||
# Get high-low battery, starting from start_pos till end
|
||||
for level in range(9,0,-1):
|
||||
for pos in range(start_pos, end_pos+1):
|
||||
if joltage[pos] != " ":
|
||||
# Skip to next if this battery has been set
|
||||
continue
|
||||
if bank[pos] == str(level):
|
||||
joltage[pos] = bank[pos]
|
||||
batteries -= 1
|
||||
batteries = set_battery(bank, joltage, pos+1, end_pos, batteries)
|
||||
if batteries == 0:
|
||||
return 0
|
||||
|
||||
# Nothing changed
|
||||
return batteries
|
||||
|
||||
|
||||
|
||||
def get_joltage(bank):
|
||||
|
||||
joltage = [" "] * len(bank)
|
||||
|
||||
set_battery(bank, joltage, 0, len(bank)-1, 12)
|
||||
|
||||
joltage_str = "".join(joltage)
|
||||
joltage_str = re.sub(" ", "", joltage_str)
|
||||
|
||||
return int(joltage_str)
|
||||
|
||||
|
||||
|
||||
def read_input(filename):
|
||||
banks = []
|
||||
for bank in open(filename).read().splitlines():
|
||||
banks.append(bank)
|
||||
return banks
|
||||
|
||||
|
||||
# filename = "day03/my_example_input"
|
||||
# filename = "day03/example_input" # 3121910778619
|
||||
filename = "day03/input" # 170147128753455
|
||||
banks = read_input(filename)
|
||||
|
||||
|
||||
total_joltage = 0
|
||||
for bank in banks:
|
||||
total_joltage += get_joltage(bank)
|
||||
|
||||
|
||||
print(f"Total joltage: {total_joltage}")
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
987654321111111
|
||||
811111111111119
|
||||
234234234234278
|
||||
818181911112111
|
||||
|
|
@ -0,0 +1,200 @@
|
|||
2235324222232244322422312234251333343425243363443152244111122632336242225745433452452451332445546443
|
||||
4342633549426242625533823432244459548433412443246235533216334436553544934221624474453562462242374424
|
||||
8434422643334243334243543423324744383442433444345133334323443723387546342444334386334543315426294343
|
||||
3314333333333253227333289433334173324336435282333332374344333346362333436223333531247332233332431333
|
||||
2432233222232224244344214455331424832252285224272831524326258455142222732648222482237235275222221622
|
||||
6456555534646565564173459654354446546674345456432576443336544564465623793536365563494844343586266956
|
||||
4922331489448743346893584377735442834632443434373231124434247962234578473993747531534353225262874382
|
||||
4329634636558644535534455549345256353469443795539452657625226416756735576575463654843527584644953254
|
||||
2454396282342313233436423353433434546123342334253853234273545734632444263222242142542533335242531345
|
||||
4635522634347741234563672633543582877478744697226363535745728883684345552215423665654453566356374355
|
||||
2224223422282212222122522222221222223222224422214224332223272212322422211242222251213213533222418262
|
||||
3333323433222542122533332343333416333236333137213354323639622333222322323353633143223233386462553523
|
||||
4464345474367222662273337653635454976376733275452394774336256334698437588364442363336256726342366843
|
||||
1222331523332222323221222212323322212432332123113224332112226241322122233222221222121233222323322226
|
||||
1144235573732262335565652436461426436275664241144242414324425444422128642454423642624133252328534342
|
||||
1524344342292446366422332163232524143645435264413335635425264332564221331257424467433633431536313333
|
||||
6522282332222324724233223129622584622214234561222231422239243441433122222452122432232132223952622232
|
||||
4155352555244325535343342355654243343155236334354554243485257534253338436555484543535584532355453534
|
||||
6468655452675256353555445144743665645455543555644546754456447542457465444555555154564425555841855936
|
||||
5222222221622121123264422214222252212213512212822212772221226222262272222622222742417215282243632241
|
||||
5434223163254553454522553225547245512224333544425332549152425254451236456645423241323554544456344256
|
||||
5424526293254361243635554415382323322225524343233622554332533455434433517232355631244233433432432528
|
||||
9321283728428452622327222344422172212235228213222223255626526312275215522352294117275122222222822241
|
||||
2298345455532222354144482748685223534841432853256544231754233422253376575254556214433252512786148479
|
||||
2122424412272742122222213122282243125211272226462222411231221252623221242221214261225722411452243222
|
||||
5427434212244142253243242124231221243224222222422324222143223242124123112124433231212242423264262123
|
||||
4454545664435434354543554374342177456567473643244355455344466354536785443248645467344424554457666475
|
||||
2322532242222322244221422243112132232323223142431222332422232122212343452232321434225124243222222322
|
||||
2622164222137423255122752492222422661893325225822224443223222823282223225272452222282422222244332225
|
||||
6354556555622355255524555375554567565654555543444564437575555375553452544564535445345525555533475554
|
||||
3221342522312282432224432443242223132122241223223121323343133414421323132214322222443262733312322232
|
||||
3224632342835254223232221243242332233232314323433156163393433112242256232276356423322232221423342323
|
||||
3222332512121224222222223221212322222122221222222322223222323122329322252213422223253122222253114232
|
||||
4222234233323423433333153233232336222453343547223172433222325534134432434213234222313144534443332335
|
||||
3221222123132222112152221122312224433223311231222122131322222222223322222224222222231213321222212221
|
||||
7326246135345245521424815232325722372711252462712232438342291624862323243242265182332123442233739437
|
||||
2433733355513566223342253543213465528552533226334364352333443355213433253157534664352433564322344123
|
||||
7756675354666543363676593566536546956757565561673943631664446365744655535285357653653525674462274967
|
||||
4323333334233333534333323334343333342233333433333243333432333334343323334332332336344335433522432433
|
||||
3333332543434532342252354343243423322441332541442534643333423124326134423661635334224124233433423174
|
||||
5235323335232417222541642263122622223822242263255324463356321141524121515424427193745222453222141334
|
||||
5886868774555746344643885473376676884344675734948355455843433537685787785745645786674574548985575575
|
||||
3547866352236644664573227563164454434563474557214356536355366554436444344465743441774145553622545244
|
||||
2454542445455454335434451454454434434474452533324232524334341443363345334445444333733546444434534343
|
||||
1232131114123623332241132222224225224222232263211324231213315372222524322142233412121735172623122225
|
||||
9267262423528474362245832533348735374544892892233421337236372142334223347313276322562331634332122245
|
||||
2223175344331222122123222233314252237251132723333321213232122532223222624333233312323452332222123222
|
||||
2313333333355313653336333333333332633333353253333336633333433234533823365342433553333233314344453153
|
||||
5323433341124332233332513233244283823243445365333343562232342421323322443533255323422433243333441213
|
||||
4525333422333222464324322731134244133112262362226244312425212143324224123334221393224333221248233213
|
||||
7543744772447787783677676778677928435645714765755486767764556624553564714656687537567755747764638674
|
||||
2363513321125441315322124323334423212227323613125424432242424252344234422122322232272123122222224142
|
||||
2433513143732523833433251632623433453233348414253337543422233332389863834322243443533343343334333642
|
||||
3323232223343324263335332467366733331323232373322232764343323323327433276326263333243343332331333124
|
||||
2221322221232233122232123241242222342222252222435242242235122222222212221234126622222213214112322332
|
||||
5536354554532533744275244143353333343253443444523343432646224933253565432536554363555645524534444536
|
||||
2422212112242637521222122322122232273272222221122322222222221212322232222231222223223211211223122222
|
||||
2222422322332345343223324223424232343432223234431232332333641334432433232423442342433351223342423222
|
||||
2247532227235434222242212232415333444344424544522422142523224424524314424432343332443424412342122424
|
||||
4495423343134452554163238453543152226335335553251337422195521742257135235734235935152333543434533974
|
||||
2222222221232222233321522231313213222122222232143212232323222232323123122121223232323321221221212233
|
||||
2433131322322136132325123312222123535312232322121252233214355225323225325567115133332223222232532513
|
||||
6648343426636674545466234347476676446534463263723454424843573354375563255343674256458722563524649566
|
||||
2281323233549441673264334423352265724433232443462436234482228223382337144646537332332774633432222535
|
||||
4221422232832221122222222222212211222231422122232221122442432122232122222235221232212112322212224312
|
||||
6122122432223246224421243724227262244522225225527332232343222122322612123224241252242213442821732312
|
||||
4542535343233343543352252333733653243422323323336733274455414363434474232432334333338333433373335953
|
||||
2212232228124222242222311222432228222182442221131222222232512222212222232322122321213722142131722222
|
||||
5485269856369364744625587696844859753855866824665868852663763638646166844169858473676295672166634584
|
||||
5555564454655565455764564539653655535468665556646655435564556546755555755465666659656563937856465517
|
||||
4522122123153322322322233226213212322324222247327212124125222822221222222272221222222222217412162221
|
||||
1222221112211322132212222223221222422322312232222222223223123123222222222121222212223222323223222222
|
||||
2233242121223121432524443142133422323232133215212342342933211323424132124231252224322233342432211244
|
||||
5333333131332333333242245322334414354233122132221234333341322334223235443234232222413334133345433243
|
||||
2132221453216322222152624232256227524322224355353322223432322132175224932664217225425632223222242243
|
||||
3232213335324743333353335343254345135373334452213325324554333333323222355336332313233125432553353362
|
||||
1232422222223222421122212123222232332212222312213122323222232221323222222322122433122432221221322223
|
||||
3234334335233363333132333333233324333323335332314423222223341334328343214371232343323333334531343323
|
||||
2322222222122322621321121242231122222122212122222222222211223222624122221222122122312122212135223322
|
||||
4854723266855228321661642462484112234275424515255353443814315282216236251423522237547317242231288321
|
||||
3366737366573633437447337543455753734345833464369237273644354443494443464735434534664746433343544446
|
||||
3622422232313342432434333437534132262444112312231222233523242234233223432363532141723222432262322342
|
||||
2238644233222253453521172222222212222222845226442223225122842535321151224622222222212526152522231633
|
||||
3434227323442221482272722224864332533622244122411727544624334414122755624122336414672452761364564231
|
||||
3235336354522334325545447733533362368545363643344435355623436335642634553423375233235533525335535355
|
||||
2122322231232321222224231322522222272232262232222275325166252242222332262224261322225122612212212225
|
||||
6431766427244447244444482435434325543313463449245454432874552543553444433235137433577322453253343225
|
||||
4233312412221224424421232221332223422632222132423311514222212322213322222513613432423222433233134321
|
||||
4333236242442222161243225636324232222443221221424221412222262224232214222342314224222224422324222642
|
||||
9425731462535333637343153525232843823112558577389452666143422343432323342223261362531324364422224464
|
||||
4443545335253335222422324353392453542133343323334344223157436233424653434241334234342434325553633142
|
||||
2112222221224332242222231223232222222231222324212432222313221141222224242222222222332222122122222232
|
||||
4424448253346263442196232222338536343325363235232557221334531732464492533223332333336223239326142324
|
||||
8273382745437262112247321123335424321325418812532342233762371571223344338246259642223244332577137353
|
||||
3643568577345257496756756647525657264356953642665544665536243455576758556265855656455638556557447456
|
||||
1146336123332555645154645654113124462456216222244452524344544156456362131466166412265552465645212789
|
||||
4423323253336333325332322323313332445332433333313335333423333632243333433633323333333323333333443134
|
||||
2232134332422232423542222143312222122222222353445552242222223223525215531343432223341441221123512221
|
||||
3388563352665326335685838248265472864333358125317224448577465733132743353843316835665356176322388136
|
||||
4343126222424222332332142623221443421524232214344222122127242453422215443442122223433432134242511245
|
||||
4232232741294227325232144222245224222453331332253552442322534342142233236432341432352242322722222232
|
||||
2333333433334213433532343333633323752224232523233623343133342333361353222763352353427443223233325222
|
||||
7622742384556724442694331499682333348332669372723424641787543253287429353635123812942325494425839212
|
||||
3443431633463243334354333433323321334234733344333333343445321333323243253224224443443383423231237361
|
||||
3322233123332423333224433325432322723344542432332223313222253262223323122342332323242214533355224211
|
||||
5536245414643455463451243331555353532554453245443432455345394352454353455595543534364352633534455334
|
||||
1337383323677353333328543446384362752123322237357487973446233239316472321236634427322223357512739785
|
||||
4245442543154463555532446444545444324444338453344555556634442844574444624544544475554344344575445445
|
||||
5227622228234266632265122722221242224652652322872437722222828145374243141871277224277276227622772122
|
||||
2445943238324523263556566333143491837242357241383752458436144244234431645366335332333322529874941472
|
||||
6542365637356542343523933333632585824545416284422325632355835215753387354465654353684647442635352646
|
||||
3567535555645454555555455565546675844544446535558433555455644556265546564553457545344646565544653555
|
||||
2332222222313444212222122222212313222213715132331222322433255332233222533222232352182231223442332122
|
||||
6242124233233222232131237332323326323323312334224832632332214323223232333322224231231331223333332132
|
||||
4473222193444229636394274424547559743225364543465343657754664282675734446284295222251874532536732413
|
||||
1622212326441562522272294367261612532425124251672424643425128334344652342222955798276224743651883432
|
||||
1374362333744223664454634866483344447343432633576333346446333146464528664536334372264254653227654645
|
||||
1353333335532221323213332323433323323532424113212262313223312221223363433334324433224624323332232133
|
||||
2252123372322223322232112223432317232122325223212233423233225222333242343433335232333211321224433242
|
||||
5233342233222226246652432233246332633215515611348646321252524221323552733213121126332465263322222444
|
||||
3434442332153513353355444524532134344445352555244132443542243443242434345453544334663223344433436155
|
||||
4624444433424434337447343443445444434442444432435454442224344542334482442514353444442242446244225643
|
||||
5622337382723222412242238223933626255262515662526534472532552294842282213225525422411232342122912162
|
||||
2792772122185564465655562269264545557358525657762127234667785274447842613355354527646138745738359454
|
||||
3246465343246123476722432534224243441353352634423334432444442644223453641633344463456335434444343354
|
||||
4443233423224543333233333434544442343463233462444374241224433224326221242324321444242473422344434342
|
||||
5423137443343444411335233742733833373344544374622435133453353333333342336332411343335255434343543111
|
||||
4563632453226354453425553264325352346626354553264455545453284274744245255444525343435453763425432446
|
||||
2233245222335422343322212442152332323322953331233312344232321423332322111221212232122431333222262242
|
||||
5562945766545795582764287247375738646786596434467544855546632566873675287544754451579464523496455865
|
||||
5224262222123223132213192123212217262222311221224211232232131222223222222232212252423222612221321122
|
||||
5144422522153311244522222222221324522224522332252523435274252122758244222245222421252322233325162335
|
||||
1424212487752147436667259652374126573126217453457523224213227566322242222373234422626252157711724692
|
||||
2453423224552435423112223453332242243525221242324422221522412322426233472333213824242132233242314524
|
||||
4223433321344422321424342224524212223325242423243243124233242422432222225225143512232225332342243322
|
||||
3344144322124124441111231222211341313141112132234144341421443243111424334124413112412432113341156789
|
||||
3423733214438543343234153433482322333217252333324224435444324423332244233433242333134333241222222223
|
||||
4253243123253153326232822254244222331452632338222222122442222123219543224333832235111133331542232322
|
||||
2222323221342322152225421332342625222222524243223435232722253225352322532322527172221245221452222222
|
||||
2222238322211222122232332224411243222621522221112221132312522512212223422223222122222222312242422312
|
||||
2254161436222322122222425521212262272251452423261221614322211373644122542524212551242442525222724161
|
||||
2252224352242364313325242232222242422131412146343242341132533342212224424221341442442314234232242312
|
||||
2539422252222352725272376321463262533245722224452315223313347473135234143342224222543343242533233436
|
||||
4266311282672157315161786415787446166768175727684645385258652611658825512185533435733352237752211459
|
||||
3382422412323362332533332233333433323433233233223322324252133453314431334332436132323322222241252323
|
||||
2212422521212222111222142153112622212222223254222132222222242212122222252222325222122223122222232242
|
||||
2221232364223124333225322322233322222322342213422322213212322333322434223512112322243231225323522434
|
||||
3732352549634766264297143323142389237291252259781845622492659412246463147653449541262628265764234623
|
||||
6554245554545453445445455954573458554345511344555443555444465255312455545555535544444434433333355394
|
||||
3513233822424124131312922122432362422443333522324257432153531243423274223233431222252332452542312472
|
||||
2535435265127353622262465444756254353338357546326631366433264475453353342474344864652365645463535534
|
||||
2222211212112232322322223222123423232122121122341322227231222222211221242122312122223221221322222222
|
||||
6555553573344343355444645555455246555545426635555364435465693655333542555455353563645664563455555538
|
||||
3336723439433762342243436534344473653364441424424224434443333444453443346344444339414354343544443444
|
||||
1322242323234322122215112223224222122323221221211431321222114221332452422224213212321232332112225243
|
||||
2558256544524445335535543454343432434455433564534453452553445552335535335143243353454464444355575545
|
||||
3356652564327455364353263324336344272412622553446354225557452323244233232525563625665455224224232335
|
||||
6273333233322222322763433233239621452263335132233252322332233323345223333255132222533463245242332333
|
||||
3321314222334222233333433322333333233232332343222333332311433432322322322333323233323313332223232443
|
||||
4321323324142522521243122328313152318236133123252263252324337143532263822723332233222431323338235212
|
||||
2421143323742373422474351343344414644632221352224112446231242422447322222233313325522224432434453324
|
||||
2222226223221222231232223322322225131111322332243232322322325152323322332134122432522514142223223213
|
||||
3336311124323433333333633441322122333232382326762333343136343121429332313233645333424333322263233332
|
||||
4122223425131211313532221211432344251543123544533321522354422524542152223414144352234434322344226789
|
||||
3753374431324644254253363333368232333322333343353264622233324517434354224213313363352531333252231343
|
||||
5447424435544446345633387344444344454444749634754443444559446358453336844244864383444444584354432668
|
||||
6322235363222463221216574322226373252452613323151424813243563523222137232235224652255522335355342226
|
||||
2233252525316222242232222522223222722232432211222232333224322223653532322232612123112355222228123322
|
||||
2226243423352324641332242443434224234422224423214247212412343444215334233423234134282212333322414624
|
||||
5453265556564498465453555553654565445515554454655545653545355539654555555956555554225454354444555454
|
||||
4433253234212342232434426224442336432533224442122341228444214222413415232372231232264333333424432334
|
||||
2323133232333221212222334323221234512344223323444332123332233272323332133243332213212333223321532263
|
||||
9349519328233523239438423843613896993215448258317133676388457727546377598132829434333513373533772423
|
||||
4666645656676966776775567597577964575666766658456577767676736646653665553545675763566785696465684676
|
||||
3333744343334355543298887212444294634472533533392532744343439433462444452344633153433463464664424367
|
||||
7651211116242563411746522426715414643134265413742514344277775633277527652747351435432146663611323589
|
||||
8337354444445333444444433345434424433433543342354754435434335434253224533422163434333327343344334653
|
||||
3322553321233233345533113137333335332353333354234545134333334253743542539333233852332332533334363333
|
||||
4322331141263364332322422832413334322422412122223222224412442143115226221233242421315528425623232331
|
||||
6345341544334342374172244444544452324334644436442245564533244344464446455233545434464442142444645443
|
||||
6564593454533545336695968366692269894591267363955467455458344474374622652552676273977443855874883692
|
||||
2222212222211222222112212212422122222121212122311222421222112212133222221122322212212422212221221212
|
||||
3233152631337353223322342261437613334633132322333133221433244346324323325334333232463334233262722343
|
||||
6626333373332133233334562512331344335364331251333233424323243633373635334324255223243443334324333333
|
||||
2333841322332225352522123742223272323613232333542322222113332233222323232313722233339225221234332223
|
||||
4557533355362533443313555257414234557533343224255435533445325432352644233634333734735138443433548225
|
||||
2223322332213632234312322324522755623325212234222213343222212223321313222232332223142222232222163132
|
||||
2122222322251222312122232222232222723222222321252323242233222342222122212217212222332222211212342233
|
||||
2615245472552234243474572652243722753243233635223225342223222721642135221132214425222474252523222335
|
||||
4345443532441442344443544545333433426444243434733243432734345445254424333736463354633542422444444323
|
||||
2322224232123433233333242325433133133322743463233433243232173533322434313433333342343722333244323334
|
||||
4422145234442334242455145125543424551223943225232242494422254314553645442334426343252214413943254425
|
||||
4465532384353243537252398442534145213673443322242656552543935464556315467556543186554424322356523243
|
||||
1222232233374372323232323323242343362123722422312632223332213312322247343423223323322241341242121313
|
||||
2211135222282222212222221222222211222642422122222214142122222432432212222211352222122622441222525121
|
||||
4144272233134434423296444643224431442442323443441442113224242324514374444664743713233133443322322233
|
||||
3435364346335235433434536431464642533325336432334433324343343348345334335513343353573432462435433445
|
||||
1322332232123333231122235282322332132233243232231243253522221182232623322312232223332213122212222333
|
||||
1332242223122322223432422223223222231321422232323322315323254332421213323312211322342222121233222222
|
||||
2122222222222321221222211222242314232222112262321222232226222422222212222222222222222221222242222212
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
811111111111119
|
||||
234234234234278
|
||||
818181911112111
|
||||
987654321111111
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -12,4 +12,10 @@ hyperfine --warmup 5 --export-json ../bram/benchmarks/data/bob-d02-p1.json \
|
|||
hyperfine --warmup 5 --export-json ../bram/benchmarks/data/bob-d02-p2.json \
|
||||
--runs 100 "python day02/day02-p2.py"
|
||||
|
||||
# Benchmark day 3
|
||||
hyperfine --warmup 5 --export-json ../bram/benchmarks/data/bob-d03-p1.json \
|
||||
--runs 100 "python day03/day03-p1.py"
|
||||
hyperfine --warmup 5 --export-json ../bram/benchmarks/data/bob-d03-p2.json \
|
||||
--runs 100 "python day03/day03-p2.py"
|
||||
|
||||
cd ../bram/benchmarks
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@ hyperfine --warmup 5 --export-json ../benchmarks/data/bram-d01-100.json \
|
|||
|
||||
# Benchmark day 2
|
||||
hyperfine --warmup 5 --export-json ../benchmarks/data/bram-d02.json \
|
||||
--runs 100 "target/release/aoc2025 2"
|
||||
--runs 100 "for run in {1..100}; do target/release/aoc2025 2; done"
|
||||
|
||||
# Benchmark day 3
|
||||
hyperfine --warmup 5 --export-json ../benchmarks/data/bram-d03.json \
|
||||
--runs 100 "for run in {1..100}; do target/release/aoc2025 3; done"
|
||||
|
||||
cd ../benchmarks
|
||||
|
|
|
|||
|
|
@ -20,4 +20,14 @@ hyperfine --warmup 5 \
|
|||
# --runs 100 "python 2-2.py"
|
||||
cd ../
|
||||
|
||||
# Benchmark day 3
|
||||
cd 3/
|
||||
hyperfine --warmup 5 \
|
||||
--export-json ../../bram/benchmarks/data/brechtje-d03-p1.json \
|
||||
--runs 100 "python 3-1.py"
|
||||
# hyperfine --warmup 5 \
|
||||
# --export-json ../../bram/benchmarks/data/brechtje-d03-p2.json \
|
||||
# --runs 100 "python 3-2.py"
|
||||
cd ../
|
||||
|
||||
cd ../bram/benchmarks
|
||||
|
|
@ -35,6 +35,24 @@
|
|||
],
|
||||
"runs": 1
|
||||
},
|
||||
{
|
||||
"name": "bob-d03-p1.json",
|
||||
"author": "Bob",
|
||||
"lang": "Python",
|
||||
"puzzles": [
|
||||
"3-1"
|
||||
],
|
||||
"runs": 1
|
||||
},
|
||||
{
|
||||
"name": "bob-d03-p2.json",
|
||||
"author": "Bob",
|
||||
"lang": "Python",
|
||||
"puzzles": [
|
||||
"3-2"
|
||||
],
|
||||
"runs": 1
|
||||
},
|
||||
{
|
||||
"name": "bram-d01-100.json",
|
||||
"author": "Bram",
|
||||
|
|
@ -53,7 +71,17 @@
|
|||
"2-1",
|
||||
"2-2"
|
||||
],
|
||||
"runs": 1
|
||||
"runs": 100
|
||||
},
|
||||
{
|
||||
"name": "bram-d03.json",
|
||||
"author": "Bram",
|
||||
"lang": "Rust",
|
||||
"puzzles": [
|
||||
"3-1",
|
||||
"3-2"
|
||||
],
|
||||
"runs": 100
|
||||
},
|
||||
{
|
||||
"name": "brechtje-d01-p1.json",
|
||||
|
|
@ -82,6 +110,15 @@
|
|||
],
|
||||
"runs": 1
|
||||
},
|
||||
{
|
||||
"name": "brechtje-d03-p1.json",
|
||||
"author": "Brechtje",
|
||||
"lang": "Python",
|
||||
"puzzles": [
|
||||
"3-1"
|
||||
],
|
||||
"runs": 1
|
||||
},
|
||||
{
|
||||
"name": "sander-d01-p1.json",
|
||||
"author": "Sander",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,218 @@
|
|||
{
|
||||
"results": [
|
||||
{
|
||||
"command": "python day03/day03-p1.py",
|
||||
"mean": 0.0660799919,
|
||||
"stddev": 0.025562380847174715,
|
||||
"median": 0.0548976352,
|
||||
"user": 0.05923819000000002,
|
||||
"system": 0.0061979943999999985,
|
||||
"min": 0.0430741142,
|
||||
"max": 0.13645839420000003,
|
||||
"times": [
|
||||
0.0580094412,
|
||||
0.0479218002,
|
||||
0.0467777452,
|
||||
0.0487909782,
|
||||
0.0568163352,
|
||||
0.054945985200000005,
|
||||
0.0873796792,
|
||||
0.1266311662,
|
||||
0.0563937692,
|
||||
0.060725026200000004,
|
||||
0.0476747372,
|
||||
0.0474197492,
|
||||
0.048355934200000006,
|
||||
0.0469648582,
|
||||
0.0478248612,
|
||||
0.04853774420000001,
|
||||
0.04466234720000001,
|
||||
0.0448723452,
|
||||
0.0439995782,
|
||||
0.05148014120000001,
|
||||
0.054453686200000004,
|
||||
0.0720802272,
|
||||
0.09020339620000001,
|
||||
0.1001945402,
|
||||
0.09638806820000001,
|
||||
0.055358244200000004,
|
||||
0.0468372552,
|
||||
0.0606053892,
|
||||
0.0638592332,
|
||||
0.0922908422,
|
||||
0.10698714220000001,
|
||||
0.1044674492,
|
||||
0.05800262120000001,
|
||||
0.04659443020000001,
|
||||
0.061099284200000006,
|
||||
0.0548101342,
|
||||
0.0468830492,
|
||||
0.0657145312,
|
||||
0.07448295020000001,
|
||||
0.059065898199999994,
|
||||
0.0443573832,
|
||||
0.0430741142,
|
||||
0.0438149122,
|
||||
0.0459145032,
|
||||
0.061378683200000006,
|
||||
0.0728903592,
|
||||
0.0977631482,
|
||||
0.1137083432,
|
||||
0.1248132872,
|
||||
0.04906956820000001,
|
||||
0.04501981120000001,
|
||||
0.046184610200000004,
|
||||
0.0436409282,
|
||||
0.054372100199999995,
|
||||
0.09953690920000001,
|
||||
0.12195182120000002,
|
||||
0.0703806292,
|
||||
0.1103826442,
|
||||
0.1260261212,
|
||||
0.0464217982,
|
||||
0.0463901332,
|
||||
0.0617853892,
|
||||
0.0548492852,
|
||||
0.044766891200000006,
|
||||
0.0536407262,
|
||||
0.11619950120000001,
|
||||
0.11864129820000001,
|
||||
0.050199670200000004,
|
||||
0.0488492802,
|
||||
0.0482894502,
|
||||
0.044182603200000004,
|
||||
0.0452517732,
|
||||
0.0507959392,
|
||||
0.060989947200000005,
|
||||
0.0620729822,
|
||||
0.044499067200000006,
|
||||
0.051901206199999994,
|
||||
0.0526471062,
|
||||
0.0627863622,
|
||||
0.0728570552,
|
||||
0.060794447200000004,
|
||||
0.0469039242,
|
||||
0.0971304202,
|
||||
0.13645839420000003,
|
||||
0.0816798682,
|
||||
0.04396929520000001,
|
||||
0.0442168822,
|
||||
0.04408973320000001,
|
||||
0.0535603102,
|
||||
0.1162714572,
|
||||
0.1043759072,
|
||||
0.12440874920000002,
|
||||
0.04929632120000001,
|
||||
0.04931024020000001,
|
||||
0.0634268662,
|
||||
0.05277431020000001,
|
||||
0.0690710262,
|
||||
0.0876780362,
|
||||
0.05742365320000001,
|
||||
0.0462994122
|
||||
],
|
||||
"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
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,218 @@
|
|||
{
|
||||
"results": [
|
||||
{
|
||||
"command": "python day03/day03-p2.py",
|
||||
"mean": 0.09414321873999999,
|
||||
"stddev": 0.01832509350311759,
|
||||
"median": 0.08736366594,
|
||||
"user": 0.08812937,
|
||||
"system": 0.005363350000000001,
|
||||
"min": 0.07237158344,
|
||||
"max": 0.14640847944000002,
|
||||
"times": [
|
||||
0.08058291244,
|
||||
0.07628245044,
|
||||
0.07969654144,
|
||||
0.09520080544,
|
||||
0.09930194044,
|
||||
0.07825368544,
|
||||
0.08392984844,
|
||||
0.07737118043999999,
|
||||
0.07788930944,
|
||||
0.07749630844,
|
||||
0.07952176043999999,
|
||||
0.09787982744,
|
||||
0.08150873044,
|
||||
0.08176495044,
|
||||
0.08633617744,
|
||||
0.10993066344,
|
||||
0.07870264444,
|
||||
0.07887313044,
|
||||
0.11759371244000001,
|
||||
0.14640847944000002,
|
||||
0.07996222643999999,
|
||||
0.09731879943999999,
|
||||
0.07707701444,
|
||||
0.07385610144,
|
||||
0.08259913244,
|
||||
0.09680778844,
|
||||
0.11890589244000001,
|
||||
0.08543212844,
|
||||
0.10530924944,
|
||||
0.07660466744,
|
||||
0.07237158344,
|
||||
0.07377316044,
|
||||
0.07496567443999999,
|
||||
0.08222708044,
|
||||
0.11440945644,
|
||||
0.12379463944,
|
||||
0.08831812944,
|
||||
0.09060156143999999,
|
||||
0.09417247944,
|
||||
0.10397773444,
|
||||
0.07700830344,
|
||||
0.07477282644,
|
||||
0.07389806843999999,
|
||||
0.08066847544,
|
||||
0.09046442344,
|
||||
0.11788687244,
|
||||
0.07385357844,
|
||||
0.07357571044,
|
||||
0.08391386544,
|
||||
0.09809230144,
|
||||
0.11828182144,
|
||||
0.11357936444,
|
||||
0.11709032343999999,
|
||||
0.09366015844,
|
||||
0.12241708644,
|
||||
0.08967856644,
|
||||
0.11136426544,
|
||||
0.10635690744,
|
||||
0.12570409044000003,
|
||||
0.08240299144,
|
||||
0.08341971044,
|
||||
0.08110020844,
|
||||
0.08025836344,
|
||||
0.07834463644,
|
||||
0.07356606644,
|
||||
0.08846380344,
|
||||
0.11980265844,
|
||||
0.08049780844,
|
||||
0.09870591944,
|
||||
0.11650581444000001,
|
||||
0.10046443644,
|
||||
0.09956565044,
|
||||
0.12974481444000002,
|
||||
0.07494186343999999,
|
||||
0.07891511344,
|
||||
0.09839348544,
|
||||
0.11864865944000001,
|
||||
0.12580707744000003,
|
||||
0.11363200844,
|
||||
0.12271954944,
|
||||
0.08420987944,
|
||||
0.12219339344,
|
||||
0.11876301444,
|
||||
0.07576832244,
|
||||
0.07380642143999999,
|
||||
0.08069492144,
|
||||
0.09729451344,
|
||||
0.10398245644,
|
||||
0.11655304443999999,
|
||||
0.07787526644,
|
||||
0.08640920244,
|
||||
0.12098887044,
|
||||
0.12086899544,
|
||||
0.11050377944,
|
||||
0.13328684144000003,
|
||||
0.09596151744,
|
||||
0.08029424943999999,
|
||||
0.07421061644,
|
||||
0.07551346744,
|
||||
0.07996589343999999
|
||||
],
|
||||
"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
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,115 +1,115 @@
|
|||
{
|
||||
"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,
|
||||
"command": "for run in {1..100}; do target/release/aoc2025 2; done",
|
||||
"mean": 0.31470294114,
|
||||
"stddev": 0.03199635516413443,
|
||||
"median": 0.32647921220000004,
|
||||
"user": 0.07126165999999999,
|
||||
"system": 0.24127882000000014,
|
||||
"min": 0.2110023297,
|
||||
"max": 0.41121181170000004,
|
||||
"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
|
||||
0.28789600470000004,
|
||||
0.29233324270000005,
|
||||
0.30447699070000006,
|
||||
0.30604592070000003,
|
||||
0.2980340227,
|
||||
0.3042085447,
|
||||
0.31601446670000005,
|
||||
0.3013712217,
|
||||
0.30324271770000005,
|
||||
0.32785871270000005,
|
||||
0.31156347370000004,
|
||||
0.31208932270000006,
|
||||
0.41121181170000004,
|
||||
0.31799863570000003,
|
||||
0.33992077270000004,
|
||||
0.3369579147,
|
||||
0.32291744670000005,
|
||||
0.3400554397,
|
||||
0.3373144127,
|
||||
0.32988819370000005,
|
||||
0.33633534470000004,
|
||||
0.32649490470000003,
|
||||
0.24973634970000003,
|
||||
0.2379149197,
|
||||
0.29469709670000005,
|
||||
0.28634381670000003,
|
||||
0.2975846407,
|
||||
0.24994015970000005,
|
||||
0.21708724270000002,
|
||||
0.22108192570000001,
|
||||
0.22381864770000004,
|
||||
0.26313973770000004,
|
||||
0.2888522747,
|
||||
0.29970076370000004,
|
||||
0.30172343970000004,
|
||||
0.3051582647,
|
||||
0.3022762097,
|
||||
0.30299157070000005,
|
||||
0.3143551627,
|
||||
0.3003338387,
|
||||
0.3045328997,
|
||||
0.32734090270000005,
|
||||
0.31374024070000006,
|
||||
0.3149945357,
|
||||
0.3232337457,
|
||||
0.3146408217,
|
||||
0.31715429170000004,
|
||||
0.34547788170000004,
|
||||
0.32486034370000005,
|
||||
0.32440604970000003,
|
||||
0.3452610607,
|
||||
0.33209796170000005,
|
||||
0.3268754427,
|
||||
0.34545075970000005,
|
||||
0.3295807727,
|
||||
0.32884609670000003,
|
||||
0.3455743927,
|
||||
0.33288479270000004,
|
||||
0.32795059870000004,
|
||||
0.3365149297,
|
||||
0.32855343470000004,
|
||||
0.33339330570000003,
|
||||
0.3473504217,
|
||||
0.3321817737,
|
||||
0.32830522870000006,
|
||||
0.34760668070000006,
|
||||
0.32824177870000004,
|
||||
0.33336813270000004,
|
||||
0.3395041267,
|
||||
0.32442966170000004,
|
||||
0.32838544070000003,
|
||||
0.3374683357,
|
||||
0.3297805757,
|
||||
0.3391899057,
|
||||
0.34050074170000005,
|
||||
0.32646351970000004,
|
||||
0.33531602070000005,
|
||||
0.33838851670000003,
|
||||
0.31628309870000004,
|
||||
0.3377080477,
|
||||
0.33689578670000003,
|
||||
0.33373161570000004,
|
||||
0.32770362470000003,
|
||||
0.3299733167,
|
||||
0.32683999970000005,
|
||||
0.34766178770000006,
|
||||
0.32503415170000005,
|
||||
0.32846571970000005,
|
||||
0.34563105270000005,
|
||||
0.33034485770000005,
|
||||
0.3304866677,
|
||||
0.34363647570000005,
|
||||
0.33028165070000004,
|
||||
0.2875129417,
|
||||
0.25051270070000003,
|
||||
0.27724555770000003,
|
||||
0.27341198070000006,
|
||||
0.29751710670000003,
|
||||
0.28160194070000005,
|
||||
0.2110023297
|
||||
],
|
||||
"exit_codes": [
|
||||
0,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,218 @@
|
|||
{
|
||||
"results": [
|
||||
{
|
||||
"command": "for run in {1..100}; do target/release/aoc2025 3; done",
|
||||
"mean": 0.2858219798399999,
|
||||
"stddev": 0.11911241840008398,
|
||||
"median": 0.2780274708,
|
||||
"user": 0.13235246999999994,
|
||||
"system": 0.15105486,
|
||||
"min": 0.1617816493,
|
||||
"max": 0.4466764503,
|
||||
"times": [
|
||||
0.27788059230000006,
|
||||
0.2339800653,
|
||||
0.30596414530000005,
|
||||
0.3035362233,
|
||||
0.3450809993,
|
||||
0.38581612130000004,
|
||||
0.3789666803,
|
||||
0.43647181030000004,
|
||||
0.42590342830000005,
|
||||
0.31160748330000004,
|
||||
0.32686600930000004,
|
||||
0.3351626803,
|
||||
0.38901525230000006,
|
||||
0.39305780130000006,
|
||||
0.35875977830000005,
|
||||
0.1675035133,
|
||||
0.1722495683,
|
||||
0.1732900133,
|
||||
0.1650050793,
|
||||
0.1776681703,
|
||||
0.1691414903,
|
||||
0.1637963703,
|
||||
0.1672267273,
|
||||
0.1617816493,
|
||||
0.1631604783,
|
||||
0.1652634953,
|
||||
0.1629138223,
|
||||
0.1650890333,
|
||||
0.1648178853,
|
||||
0.1637581273,
|
||||
0.1643174363,
|
||||
0.1636355433,
|
||||
0.1640868523,
|
||||
0.1647233763,
|
||||
0.1639534483,
|
||||
0.1621999673,
|
||||
0.1637627413,
|
||||
0.1648785603,
|
||||
0.1635657323,
|
||||
0.1697515313,
|
||||
0.1665315373,
|
||||
0.1664922383,
|
||||
0.1636477263,
|
||||
0.2015597083,
|
||||
0.4399764453,
|
||||
0.43566508130000003,
|
||||
0.43843071530000005,
|
||||
0.43717739930000005,
|
||||
0.44117839430000005,
|
||||
0.4383437143,
|
||||
0.44289095930000005,
|
||||
0.4466764503,
|
||||
0.4340191983,
|
||||
0.38891430530000004,
|
||||
0.31792457430000004,
|
||||
0.2781743493,
|
||||
0.29652729530000005,
|
||||
0.32400008430000005,
|
||||
0.32573575130000004,
|
||||
0.3552500223,
|
||||
0.35653021730000006,
|
||||
0.39221699330000004,
|
||||
0.41257687630000006,
|
||||
0.4055779453,
|
||||
0.43111143530000007,
|
||||
0.40042304130000006,
|
||||
0.4412894613,
|
||||
0.41781259530000003,
|
||||
0.1854528053,
|
||||
0.1701201473,
|
||||
0.1779843383,
|
||||
0.1683290163,
|
||||
0.1667868963,
|
||||
0.1811534223,
|
||||
0.1681221393,
|
||||
0.1662736183,
|
||||
0.1715112723,
|
||||
0.1702715243,
|
||||
0.1678216483,
|
||||
0.1684258623,
|
||||
0.1685099203,
|
||||
0.1660978933,
|
||||
0.1630387413,
|
||||
0.1848142833,
|
||||
0.1995848083,
|
||||
0.1675094073,
|
||||
0.2163439033,
|
||||
0.4370722463,
|
||||
0.44037415930000007,
|
||||
0.43945498130000005,
|
||||
0.43611861930000007,
|
||||
0.44157850230000006,
|
||||
0.43407264630000003,
|
||||
0.4394844613,
|
||||
0.43866582230000006,
|
||||
0.4372620253,
|
||||
0.43830210030000005,
|
||||
0.44074636130000006,
|
||||
0.4378032733,
|
||||
0.4408469393
|
||||
],
|
||||
"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
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,218 @@
|
|||
{
|
||||
"results": [
|
||||
{
|
||||
"command": "python 3-1.py",
|
||||
"mean": 0.04121359861,
|
||||
"stddev": 0.01925979464565644,
|
||||
"median": 0.03321260526,
|
||||
"user": 0.033925540000000004,
|
||||
"system": 0.006530669999999996,
|
||||
"min": 0.02099105726,
|
||||
"max": 0.08260498326,
|
||||
"times": [
|
||||
0.051904651260000004,
|
||||
0.07081237026000001,
|
||||
0.07550464926,
|
||||
0.07386956426,
|
||||
0.05226041826000001,
|
||||
0.02245401626,
|
||||
0.021673267260000004,
|
||||
0.022984726260000005,
|
||||
0.021070968260000003,
|
||||
0.022354786260000002,
|
||||
0.02207817326,
|
||||
0.02265223326,
|
||||
0.022228742260000003,
|
||||
0.021890656260000002,
|
||||
0.027320925260000004,
|
||||
0.027147791260000005,
|
||||
0.02660499526,
|
||||
0.033888322260000006,
|
||||
0.05204111326000001,
|
||||
0.07783879126000001,
|
||||
0.07545674326,
|
||||
0.07537733826000001,
|
||||
0.07891184926,
|
||||
0.07663281226,
|
||||
0.08194317426,
|
||||
0.07275445526,
|
||||
0.02677728226,
|
||||
0.02146064626,
|
||||
0.02126091226,
|
||||
0.022596147260000005,
|
||||
0.025912396260000005,
|
||||
0.02637571726,
|
||||
0.029881821260000004,
|
||||
0.032719728260000004,
|
||||
0.037371311260000005,
|
||||
0.04147204526000001,
|
||||
0.02693493626,
|
||||
0.02099105726,
|
||||
0.021683471260000003,
|
||||
0.02325691926,
|
||||
0.030879524260000006,
|
||||
0.037412061260000004,
|
||||
0.053491290260000005,
|
||||
0.057412962260000006,
|
||||
0.05373986226000001,
|
||||
0.028096754260000002,
|
||||
0.06869860526,
|
||||
0.07218100526,
|
||||
0.05327467526,
|
||||
0.025161592260000004,
|
||||
0.024661289260000004,
|
||||
0.02454142426,
|
||||
0.025319026260000002,
|
||||
0.03712941226,
|
||||
0.049977244260000005,
|
||||
0.07055158726,
|
||||
0.048365752260000006,
|
||||
0.05857217026,
|
||||
0.06317722226,
|
||||
0.04863136826,
|
||||
0.06011220426000001,
|
||||
0.041733240260000005,
|
||||
0.047502842260000004,
|
||||
0.038220037260000006,
|
||||
0.058726324260000004,
|
||||
0.061521019260000004,
|
||||
0.024227173260000005,
|
||||
0.029794275260000003,
|
||||
0.03370548226,
|
||||
0.04198545126,
|
||||
0.044787625260000005,
|
||||
0.05080426326,
|
||||
0.047328115260000005,
|
||||
0.025825472260000003,
|
||||
0.02565365126,
|
||||
0.026707547260000006,
|
||||
0.027339551260000004,
|
||||
0.025979196260000004,
|
||||
0.027713986260000004,
|
||||
0.030965964260000006,
|
||||
0.07263531026,
|
||||
0.05937729026000001,
|
||||
0.02620647526,
|
||||
0.030743662260000006,
|
||||
0.03128535526,
|
||||
0.04805048926,
|
||||
0.08260498326,
|
||||
0.07357149826,
|
||||
0.046451266260000006,
|
||||
0.025180880260000003,
|
||||
0.028250977260000004,
|
||||
0.036459030260000004,
|
||||
0.07202390626,
|
||||
0.045909026260000006,
|
||||
0.021836287260000004,
|
||||
0.02222378926,
|
||||
0.022240946260000005,
|
||||
0.021696904260000004,
|
||||
0.021384970260000004,
|
||||
0.02296663626
|
||||
],
|
||||
"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: 48 KiB After Width: | Height: | Size: 49 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
|
|
@ -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
|
||||
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,50 +1,189 @@
|
|||
use crate::utils;
|
||||
use std::ops::RangeInclusive;
|
||||
use std::collections::HashMap;
|
||||
|
||||
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()
|
||||
)
|
||||
use crate::utils;
|
||||
|
||||
pub fn answer(text : String) -> ( u128, u128 ) {
|
||||
text.trim()
|
||||
.split(",")
|
||||
.flat_map(Range::from)
|
||||
.map(|range| range.invalid_id_sum())
|
||||
.fold((0, 0), |(x1, y1), (x2, y2)| (x1 + x2, y1 + y2))
|
||||
}
|
||||
|
||||
fn is_invalid(n : &u64) -> bool {
|
||||
for b in 2..=10 {
|
||||
if is_invalid_by(n, b) {
|
||||
return true;
|
||||
struct Range {
|
||||
low : String,
|
||||
high : String,
|
||||
}
|
||||
impl Range {
|
||||
fn from(s : &str) -> Vec<Range> {
|
||||
let mut ranges : Vec<Range> = Vec::new();
|
||||
|
||||
let (low, high) = match s.split_once("-") {
|
||||
Some(pair) => pair,
|
||||
None => return Vec::new(),
|
||||
};
|
||||
|
||||
// Sanitize input - for AoC, optional
|
||||
if low.len() > high.len() { return Vec::new() }
|
||||
if low.bytes().any(|c| c < b'0' || c > b'9') { return Vec::new() }
|
||||
if high.bytes().any(|c| c < b'0' || c > b'9') { return Vec::new() }
|
||||
|
||||
for size in low.len()..=high.len() {
|
||||
let range = Range::new(
|
||||
if low.len() == size {
|
||||
String::from(low)
|
||||
} else {
|
||||
std::iter::once('1')
|
||||
.chain(std::iter::repeat('0').take(size - 1))
|
||||
.collect()
|
||||
},
|
||||
if high.len() == size {
|
||||
String::from(high)
|
||||
} else {
|
||||
std::iter::repeat('9').take(size).collect()
|
||||
},
|
||||
);
|
||||
|
||||
ranges.push(range);
|
||||
}
|
||||
|
||||
ranges
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
fn has_pattern(&self, s : &str) -> bool {
|
||||
assert!(s.len() > 0);
|
||||
assert!(s.len() < self.len());
|
||||
assert_eq!(self.len() % s.len(), 0);
|
||||
|
||||
fn is_invalid_by(n : &u64, by : usize) -> bool {
|
||||
let s : String = n.to_string();
|
||||
let size : usize = s.len() / by;
|
||||
for (l, c) in self.low.chars().zip(s.chars().cycle()) {
|
||||
if l < c {
|
||||
break;
|
||||
} else if l > c {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if s.len() % by == 0 {
|
||||
for i in 1..by {
|
||||
if s[0..size] != s[i * size..(i + 1) * size] {
|
||||
for (h, c) in self.high.chars().zip(s.chars().cycle()) {
|
||||
if c < h {
|
||||
break;
|
||||
} else if c > h {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
fn invalid_id_sum(&self) -> ( u128, u128 ) {
|
||||
// Part 1
|
||||
( if self.len() % 2 == 0 {
|
||||
self.total_of_pattern_size(self.len() / 2)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
// Part 2
|
||||
, self.pattern_hashmap().values().sum()
|
||||
)
|
||||
}
|
||||
|
||||
fn len(&self) -> usize {
|
||||
self.low.len()
|
||||
}
|
||||
|
||||
fn new(low : String, high : String) -> Range {
|
||||
// Verify they're the same length
|
||||
assert_eq!(low.len(), high.len());
|
||||
|
||||
// Verify they're all 0-9
|
||||
assert!(low.chars().all(|c| '0' <= c && c <= '9'));
|
||||
assert!(high.chars().all(|c| '0' <= c && c <= '9'));
|
||||
|
||||
// Verify they're in order
|
||||
for (l, h) in low.chars().zip(high.chars()) {
|
||||
assert!(l <= h);
|
||||
|
||||
if l < h {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Range{ low : low, high : high }
|
||||
}
|
||||
|
||||
// Create a HashMap that counts the number of patterns for each value
|
||||
fn pattern_hashmap(&self) -> HashMap<usize, u128> {
|
||||
let mut h : HashMap<usize, u128> = HashMap::new();
|
||||
|
||||
// Populate the HashMap
|
||||
for size in 1..=(self.len() / 2) {
|
||||
if self.len() % size == 0 {
|
||||
let mut patterns : u128 = self.total_of_pattern_size(size);
|
||||
|
||||
// We'll double count a few patterns.
|
||||
// For example,
|
||||
//
|
||||
// 247247 247247
|
||||
// |------|------|
|
||||
//
|
||||
// this number is a pattern of 6, but it is also a pattern of 3! (lol)
|
||||
// 6-patterns always catch ALL 3-patterns. In fact, all
|
||||
// k-patterns are always caught by n-patterns iff k | n.
|
||||
// Therefore, if we want to accurately count the number of
|
||||
// 6-patterns that AREN'T already counted as 1-patterns,
|
||||
// 2-patterns or 3-patterns, we must subtract our total by
|
||||
// those amounts.
|
||||
for (key, value) in h.iter() {
|
||||
|
||||
if size % key == 0 {
|
||||
patterns -= value;
|
||||
}
|
||||
}
|
||||
|
||||
h.insert(size, patterns);
|
||||
}
|
||||
}
|
||||
|
||||
h
|
||||
}
|
||||
|
||||
// Count all invalid IDs where the pattern is of a given size.
|
||||
// Then count the numbers of those chunks.
|
||||
// These can then be re-used to count the full value efficiently.
|
||||
fn total_of_pattern_size(&self, size : usize) -> u128 {
|
||||
// 1. Find the range of all patterns of size `size`
|
||||
let inf_str: &str = self.low.get(0..size).unwrap();
|
||||
let sup_str: &str = self.high.get(0..size).unwrap();
|
||||
|
||||
let inf : u128 = if self.has_pattern(inf_str) {
|
||||
utils::str_to_u128(inf_str).unwrap()
|
||||
} else {
|
||||
utils::str_to_u128(inf_str).unwrap() + 1
|
||||
};
|
||||
let sup : u128 = if self.has_pattern(sup_str) {
|
||||
utils::str_to_u128(sup_str).unwrap()
|
||||
} else {
|
||||
utils::str_to_u128(sup_str).unwrap() - 1
|
||||
};
|
||||
|
||||
// No patterns exist!
|
||||
if inf > sup {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 2. Calculate the sum of the pattern snippets
|
||||
let pattern_sum : u128 = ((sup - inf + 1) * (inf + sup)) / 2;
|
||||
|
||||
// 3. Calculate the sum of the patterns when they repeat themselves.
|
||||
// For example:
|
||||
// Step 2 calculated the sum of x = 123 + 124 + 125
|
||||
// Step 3 calculates the sum of
|
||||
// y = 123123123 + 124124124 + 125125125
|
||||
// by realizing that:
|
||||
// y = 1001001 * (123 + 124 + 125) = 100100100 * x
|
||||
// = (10^6 + 10^3 + 10^0) * x
|
||||
let layers : usize = self.len() / size;
|
||||
let factor : u128 = (0..layers).map(|layer| 10u128.pow((size * layer) as u32)).sum();
|
||||
|
||||
factor * pattern_sum
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
use crate::utils;
|
||||
|
||||
pub fn answer(text : String) -> ( u32, u32 ) {
|
||||
( 0, 0 )
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
mod day_01;
|
||||
mod day_02;
|
||||
// mod day_03;
|
||||
// mod day_04;
|
||||
mod day_03;
|
||||
mod day_04;
|
||||
// mod day_05;
|
||||
// mod day_06;
|
||||
// mod day_07;
|
||||
|
|
@ -33,19 +33,19 @@ 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");
|
||||
// let (p1, p2, d) = diagnostics::benchmark(s, day_04::answer);
|
||||
pub fn day_04() -> DailyOutput {
|
||||
let s : String = read_from_file("inputs/04.txt");
|
||||
let (p1, p2, d) = diagnostics::benchmark(s, day_04::answer);
|
||||
|
||||
// ( p1 as u128, p2 as u128, d )
|
||||
// }
|
||||
( p1 as u128, p2 as u128, d )
|
||||
}
|
||||
|
||||
// pub fn day_05() -> DailyOutput {
|
||||
// let s : String = read_from_file("inputs/05.txt");
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ fn main() {
|
|||
|
||||
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(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),
|
||||
|
|
@ -30,8 +30,8 @@ fn run_all_days() {
|
|||
|
||||
aoc.insert(1, aoc2025::day_01());
|
||||
aoc.insert(2, aoc2025::day_02());
|
||||
// aoc.insert(3, aoc2025::day_03());
|
||||
// aoc.insert(4, aoc2025::day_04());
|
||||
aoc.insert(3, aoc2025::day_03());
|
||||
aoc.insert(4, aoc2025::day_04());
|
||||
// aoc.insert(5, aoc2025::day_05());
|
||||
// aoc.insert(6, aoc2025::day_06());
|
||||
// aoc.insert(7, aoc2025::day_07());
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ use std::fs;
|
|||
|
||||
pub mod diagnostics;
|
||||
|
||||
pub fn char_to_u8(c : char) -> Option<u8> {
|
||||
c.to_digit(10).and_then(|n| u8::try_from(n).ok())
|
||||
}
|
||||
|
||||
// pub fn char_to_u64(s : char) -> Option<u64> {
|
||||
// s.to_string().parse::<u64>().ok()
|
||||
// }
|
||||
|
|
@ -39,3 +43,7 @@ pub fn str_to_i16(s : &str) -> Option<i16> {
|
|||
pub fn str_to_u64(s : &str) -> Option<u64> {
|
||||
s.trim().to_string().parse::<u64>().ok()
|
||||
}
|
||||
|
||||
pub fn str_to_u128(s : &str) -> Option<u128> {
|
||||
s.trim().to_string().parse::<u128>().ok()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
input = open("input.txt").read().splitlines()
|
||||
|
||||
# line = current line that is being searched
|
||||
# start = at what index to start searching
|
||||
# for the first digit: 0
|
||||
# for the second digit: right after the index of the first digit
|
||||
# is_first_digit = boolean, True if first digit is being found, False if second digit is being found
|
||||
# num_to_find = (next) number to search for in the string (line), starts at 9 decreases when not found
|
||||
def find_biggest_num_index(line, start, is_first_digit):
|
||||
index = -1
|
||||
num_to_find = 9
|
||||
while True:
|
||||
index = line.find(str(num_to_find), start)
|
||||
# decrease num_to_find if number is not found
|
||||
# OR we are currently searching for the first digit and the number found is the last char in the string
|
||||
if index == -1 or (is_first_digit and index == len(line) - 1):
|
||||
num_to_find -= 1
|
||||
else:
|
||||
return index
|
||||
answer = 0
|
||||
|
||||
for line in input:
|
||||
first_digit_index = find_biggest_num_index(line, 0, True)
|
||||
second_digit_index = find_biggest_num_index(line, first_digit_index + 1, False)
|
||||
answer += int(line[first_digit_index] + line[second_digit_index])
|
||||
|
||||
print(answer)
|
||||
Loading…
Reference in New Issue