Compare commits

...

2 Commits

Author SHA1 Message Date
pegasust 0547d489ba d8: add data 2022-12-08 05:01:20 +00:00
pegasust b2602f9666 init d8 2022-12-08 03:56:00 +00:00
8 changed files with 234 additions and 0 deletions

4
2022/d8/.envrc Normal file
View File

@ -0,0 +1,4 @@
if command -v nix-shell &> /dev/null
then
use flake
fi

1
2022/d8/README.md Normal file
View File

@ -0,0 +1 @@
# Bootstrapping clojure project on

5
2022/d8/data/example.txt Normal file
View File

@ -0,0 +1,5 @@
30373
25512
65332
33549
35390

100
2022/d8/data/submission.txt Normal file
View File

@ -0,0 +1,100 @@
133120320210233440424211425033311533112110111336536142004454550513525522325223123404213204010312200
201131111014211324423255354022022243226445013613610423653614522135534505055120330313403031333103010
312033232323231244025301315245341424106564334260061464515142114141551050411122254121204214442432210
101223224313414001513045124413405604251532415616200623342234245060512030200002055453441222043022132
302000022010423415300513533001221654231646352603366222420353100303160621313144421120541324031322221
022041343104313414435021243154525050055065506466215004364316065443031303052541012204020300331224312
103341401201343234101335152026143021665443260024145323023321363412215203352344024010350241320230403
113420142141151035404302242616255522460104100534576523546245441245051223305614204355454223220120301
141313120334140413444311032422155464031057323373712672513175353623531154646460010504312302300002224
222122233241135333145102102244620325637577115357373355166254434732406430504542404102101335430322111
303334221050505214133200215501142243567431213624743475716112467711442460620524310041114411011423020
314200333004550151023253063621162447552734266222424315622125733562141045411643325165010440012411104
002041023423222500521530364652321342767176666734452465675417573276212213343035032650010252311440041
424112310115314154624123026322722176144615437667237551164455332134452657635041110204303331153310423
403331525242111322464321027125164326531546671615634451453753666614652523355664316050035035431040223
043240150545010061116502263626227235517673287377662722735257631252161774623714640414211242003124031
120153432445266666010553121747235535567222344854553227754373283562766712275433030145041514430322020
130205252451225625553367153422361135376345652238658565468884466665635712475577163231554521534443142
111112125502543266131422234726554665525278247588365447865236325776254766323137341434403365242323513
303144132003506154604725457356146262354554756268227328243768455722852644644163423635454133132303535
355321430425362320027571672735837582654822875282477453446323242873743335342262324741355251635040132
134315335666154514547724226424352647855667536237263286847676436882327536177762242121655513144251300
540433012152253201644772517187257277883368828477658659796427367852347254442546347411045431414354124
123440236041532033152645165666552487887293658447738333978367787858534683322123676621510536503333401
513523462114216537146475772264724378429935336847846348444575554346687726237537112655265045664650022
152254463440132245722174776775434287876777476649865634494799993998688326736773121545343121065304241
250224151321236513227671833576566739347663376834388478944395578563955424353347453672417622666244155
515223301360505722213752783545553644495694566664938776366634393433784855746658113613537562051065554
554241245610333147211334537367835857366454575934899676895788946595666473766285253431355325406031452
100314521636253352672223432738853968767459797559486648888395749643933624738538781345525612342532041
341462234622615555235573736647638675877393747847457878744844899855446378852378466172227414636330202
345125124225634624432677378235488673587578945954767695474694483979633396738646725252521775306550112
413420352557414334236458423883348897736674897485778466695756868398399557654674634472471146623221025
251143521254271126368347667353953675589776644454498798849645686658369675764886773874127564444411365
221413142252611772737673846553885549867478965666795885777985495763559573589863845361134756354652555
243065641366675316826485533843887969469458797465896675796454946875597936434758642384462157714462066
520553502161266638252882759578566955579648578498775589886979787578896857766344736358531725733564135
424035430516117723442423478595343855468789497988556567558494878666699996375768427758374271236421335
252313015177661777278432468494855844559656687766987679695575558744879656544795683583262246546564621
066230444571526644743382974447835556985988567697575656976987588986595376466888728567376162756500435
466346066733165454546438886894789699679455689766757985688888664759568963398874674733715475614334101
325014552177542688745486585579599747867559596676796865787567755944786444539663262282351475561402534
241163303516225237353826934978454869995779765759887659668665685578986859343646684568651136735352562
450361264326612736655359595445797648876877955597997887987765775498545883744548752574473726565411112
554605215356217343577344399893857478777797855566878769757669857854854856357865565536552164136515351
526446641376374684266375494495458695869978975788699978669887967564769488567376982882762633361324360
131314671231526545866684867949989786895865986986978678997899677764988874736369482822342624761635224
623254034413371684428636874768586849979569867987768799666579796798469744978968758623884477174221325
451620621666445477562568544366499474968796999686779676678989576768596484478933764745243527321126622
454130052341168772645439448775675586969558878998779766779998798589986885955369648636673756137543515
052463667567627485865289577459895546659595768687867979887989666587865576357344373227477771625616331
460630633631764266522893997758984967975685969969798677679989558694657986684466928784764257141450213
624130637644652532575536775488944945689777797679988979876565896659695947897698966634635115577122034
312106635521463635433584476586795448766769568869779667989675669974989668369378542526764316562641343
162151455625714643563689555468449898859656786796979798687579985864586658783373657585741615177725655
522113305657225658843435489885646557577988797667968888669868768989959977879557377455733555272325032
304510566333111422674633384687874565587979787768979689685867565897484896499888736286384551117254613
501463041455354857783745556844585568845776985978966685877875599798784456633539465754543114144204310
033044042511137887672349889484876755578886688778959586777755687684946795536886522746575472552603266
506221035322726455557224463853355996897775558969955685797667999588974556935495475632746634441041151
433136161743725565262636565676447685475989796568778598958657768879849778786859753335661722543205305
265454361556653132263478888989675487694888975877759959776785674478666588788563747772733262666414514
052441631644734262283652379957577654769979687765967795697668686969788694345962866843241632716655446
236003436545632166356247457495793686988694668988898785686844466844799668333966735544674562633412352
521460600027621624875854349394389587767654998655578976768847769685597639387383648267451531624063352
342222114334344716267243334967869638699594976567878976765649455495834476654882454551336614731204621
033566313156263553885434364795389663465876465857797479766958478858465479967473865454116236530266023
312652012603144155543338267594667756579949844587785799854455597889659839838335338227724422251205254
300006533237512225736566526838475448787546947968579975977675656694697397732838257677271224106345603
133143326544516157647526755363599347754745759889457964588954897669586537634253625642342472416641244
154255220262671713413357272553997888597745494647794956965689397737688378433337485552276212554465555
100240040401314462336283253854484757937369955476776566463546476496874852334852883176722554655020500
114224164252562264455188387248845988369836588899857935337746669656565572827235667727764740332042104
210035410165643165676172383567428973379998596753776399638478657839665546428878531777515004325230423
210124643010215635561443542385838474565467799589387569934754637575772733563765332372676641151131504
302221012422133674231332744234367852633548864367379437949776375866557752335873376756770315423300102
332125266633066263556242566636554222886478446383395355568773939525563625678526672212234343222625410
025325451166410144267526457225543863563576656495967865696633785745578788783545643421165350000423343
002055431510265615765734547166486528454663847694453963495886284323368575223225414276066312104153401
355245141260142612771253626632378444477523462347872628387736452238277834561572523626005254261254042
203545210065351052363237141625823577635472367448676276452678742864237273162112414622640501555430121
335510044411666505051763342712375473385677658477545568853568734655885763312211631300144242225254322
420503535251235101224431771412136627846753333256668624663675776462422374227471570160056336045543305
311442220344522144201454355125161416822475756464544562823568565277363143626236634605524051151344323
221042430004563020306242752654674353744234455564453257548654537765566764222366445225313642034222311
410315020300414623613025143245525766347157877736466252545465214236744364172443246502214503112203230
342304354225251006345461616171626576425171512572743837515273314522745717111151266035240243530314400
101402542354002125435251304674647534521162334775342133371111747561164265140621412560624450505304430
011211315525203435452400223603127166746242764515517634515312173434163762164444142306041434112503201
312201041521122523410120106532007714457744313215145447526753371116262403622123305243410143403304001
420143230433241404304622552610552657576751252637557577175144676122663421114064036341501055504120312
321114124142324224151525015553652243236362311234247651266113535462142056365353412114023231401141232
144010233331150422332523034411415500511027722375253755262514425243333354512150011301540445044301243
321223141143321313415515024451144622413543514327723454716501265226013550620005111202312303242203422
220312222242043544521300416060642531526303363025212311016020154415132623214322110011054242222314401
120043213410140522500232142235034335033562221102412305131143065020436150033340525535242031300403012
333011210021031104353104420453564321600565055235040060414452305642301521213234000231332120021102311
213000422032423433105500120521112552552162045443040565055142555024614151234210022135411312102303010
311113213314300134505043355233124354500023350433035532626242646113034040102425400244311432332422101

43
2022/d8/flake.lock Normal file
View File

@ -0,0 +1,43 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1670064435,
"narHash": "sha256-+ELoY30UN+Pl3Yn7RWRPabykwebsVK/kYE9JsIsUMxQ=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "61a8a98e6d557e6dd7ed0cdb54c3a3e3bbc5e25c",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

64
2022/d8/flake.nix Normal file
View File

@ -0,0 +1,64 @@
{
description = "D4 AOC with Lua!";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { nixpkgs, flake-utils, ... } @ inputs:
flake-utils.lib.eachSystem flake-utils.lib.defaultSystems (sys:
let
overlays = [ ];
pkgs = import nixpkgs { system = sys; overlays = overlays; };
shellHookAfter = ''
echo "The input files should be placed under ./data/{submission,example}.txt"
echo "This problem shares one input between two parts"
'';
py_pkgs = [ pkgs.python310 ];
ocamlPackager = pkgs.ocaml-ng.ocamlPackages_4_14;
ocaml_pkgs = let inherit (ocamlPackager) ocaml findlib dune_2 ocaml-lsp; in
[ ocaml findlib dune_2 ocaml-lsp ];
ocaml_build_pkgs = [ ocamlPackager.ocamlgraph ];
in
{
# Jack of all trades
devShell = pkgs.mkShell
{
nativeBuildInputs = py_pkgs ++ ocaml_pkgs;
shellHook = ''
echo "> Default runtime. This contains both ocaml and python3 env"
echo "Run ./run-py.sh for Python's output and ./run-oml.sh for OCaml's output"
'' + shellHookAfter;
};
devShells = {
# nix develop ./#lua
# lua = pkgs.mkShell {
# nativeBuildInputs = lua_pkgs;
# shellHook = ''
# echo "> Lua runtime"
# echo "Run ./run-lua.sh to see the output of the solution"
# '' + shellHookAfter;
# };
# nix develop ./#fennel
ocaml = pkgs.mkShell
{
nativeBuildInputs = ocaml_pkgs;
shellHook = ''
echo "> OCaml runtime"
echo "Run ./run-oml.sh to see output of OCaml solution"
'' + shellHookAfter;
};
# nix develop ./#python
python = pkgs.mkShell {
nativeBuildInputs = py_pkgs;
shellHook = ''
echo "> Python3 runtime"
echo "Run ./run-py.sh to see the output of the solution"
'' + shellHookAfter;
};
};
}
);
}

7
2022/d8/run-py.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env sh
echo "example"
python3 ./src/d8.py ./data/example.txt
echo "submission"
python3 ./src/d8.py ./data/submission.txt

10
2022/d8/src/d8.py Normal file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env python3
import sys
from typing import Iterable
def main(lines: Iterable[str]):
pass
if __name__=="__main__":
with open(sys.argv[1], "r") as f:
main(f)