A => .cargo/config.toml +3 -0
@@ 1,3 @@
+[target.x86_64-unknown-linux-gnu]
+linker = "clang"
+rustflags = ["-C", "link-arg=-fuse-ld=mold"]
A => .envrc +1 -0
A => .gitignore +3 -0
@@ 1,3 @@
+/.direnv/
+/.pre-commit-config.yaml
+/target/
A => Cargo.lock +244 -0
@@ 1,244 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "anstream"
+version = "0.6.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
+dependencies = [
+ "anstyle",
+ "anstyle-parse",
+ "anstyle-query",
+ "anstyle-wincon",
+ "colorchoice",
+ "is_terminal_polyfill",
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle"
+version = "1.0.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
+
+[[package]]
+name = "anstyle-parse"
+version = "0.2.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
+dependencies = [
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle-query"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
+dependencies = [
+ "windows-sys",
+]
+
+[[package]]
+name = "anstyle-wincon"
+version = "3.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"
+dependencies = [
+ "anstyle",
+ "windows-sys",
+]
+
+[[package]]
+name = "anyhow"
+version = "1.0.93"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775"
+
+[[package]]
+name = "aoc2024"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "clap",
+]
+
+[[package]]
+name = "clap"
+version = "4.5.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f"
+dependencies = [
+ "clap_builder",
+ "clap_derive",
+]
+
+[[package]]
+name = "clap_builder"
+version = "4.5.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec"
+dependencies = [
+ "anstream",
+ "anstyle",
+ "clap_lex",
+ "strsim",
+]
+
+[[package]]
+name = "clap_derive"
+version = "4.5.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "clap_lex"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7"
+
+[[package]]
+name = "colorchoice"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
+
+[[package]]
+name = "heck"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
+
+[[package]]
+name = "is_terminal_polyfill"
+version = "1.70.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.92"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.37"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "strsim"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
+
+[[package]]
+name = "syn"
+version = "2.0.90"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
+
+[[package]]
+name = "utf8parse"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
+
+[[package]]
+name = "windows-sys"
+version = "0.59.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
+
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
A => Cargo.toml +10 -0
@@ 1,10 @@
+[package]
+name = "aoc2024"
+version = "0.1.0"
+authors = ["Jonni Liljamo <jonni@liljamo.com>"]
+edition = "2021"
+publish = false
+
+[dependencies]
+anyhow = "1"
+clap = { version = "4", features = ["derive"] }
A => flake.lock +146 -0
@@ 1,146 @@
+{
+ "nodes": {
+ "flake-compat": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1696426674,
+ "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
+ "flake-parts": {
+ "inputs": {
+ "nixpkgs-lib": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1730504689,
+ "narHash": "sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS+b4tfNFCwE=",
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
+ "rev": "506278e768c2a08bec68eb62932193e341f55c90",
+ "type": "github"
+ },
+ "original": {
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
+ "type": "github"
+ }
+ },
+ "gitignore": {
+ "inputs": {
+ "nixpkgs": [
+ "pre-commit-hooks",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1709087332,
+ "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
+ "type": "github"
+ },
+ "original": {
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1733024928,
+ "narHash": "sha256-n/DOfpKH1vkukuBnach91QBQId2dr5tkE7/7UrkV2zw=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "2c27ab2e60502d1ebb7cf38909de38663f762a79",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs-stable": {
+ "locked": {
+ "lastModified": 1730741070,
+ "narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "d063c1dd113c91ab27959ba540c0d9753409edf3",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixos-24.05",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "pre-commit-hooks": {
+ "inputs": {
+ "flake-compat": "flake-compat",
+ "gitignore": "gitignore",
+ "nixpkgs": [
+ "nixpkgs"
+ ],
+ "nixpkgs-stable": "nixpkgs-stable"
+ },
+ "locked": {
+ "lastModified": 1732021966,
+ "narHash": "sha256-mnTbjpdqF0luOkou8ZFi2asa1N3AA2CchR/RqCNmsGE=",
+ "owner": "cachix",
+ "repo": "git-hooks.nix",
+ "rev": "3308484d1a443fc5bc92012435d79e80458fe43c",
+ "type": "github"
+ },
+ "original": {
+ "owner": "cachix",
+ "repo": "git-hooks.nix",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-parts": "flake-parts",
+ "nixpkgs": "nixpkgs",
+ "pre-commit-hooks": "pre-commit-hooks",
+ "rust-overlay": "rust-overlay"
+ }
+ },
+ "rust-overlay": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1733020719,
+ "narHash": "sha256-Chv9+3zrf1DhdB9JyskjoV0vJbCQEgkVqrU3p4RPLv8=",
+ "owner": "oxalica",
+ "repo": "rust-overlay",
+ "rev": "8e18f10703112e6c33e1c0d8b93e8305f6f0a75c",
+ "type": "github"
+ },
+ "original": {
+ "owner": "oxalica",
+ "repo": "rust-overlay",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
A => flake.nix +97 -0
@@ 1,97 @@
+{
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
+ flake-parts = {
+ url = "github:hercules-ci/flake-parts";
+ inputs.nixpkgs-lib.follows = "nixpkgs";
+ };
+
+ pre-commit-hooks = {
+ url = "github:cachix/git-hooks.nix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+
+ rust-overlay = {
+ url = "github:oxalica/rust-overlay";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ };
+
+ outputs = inputs @ {
+ self,
+ nixpkgs,
+ flake-parts,
+ pre-commit-hooks,
+ rust-overlay,
+ ...
+ }:
+ flake-parts.lib.mkFlake {inherit inputs;} {
+ systems = ["x86_64-linux"];
+ perSystem = {
+ config,
+ lib,
+ pkgs,
+ system,
+ ...
+ }: let
+ toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
+ libs = [];
+ in {
+ _module.args.pkgs = import inputs.nixpkgs {
+ inherit system;
+ overlays = [inputs.rust-overlay.overlays.default];
+ };
+
+ checks.pre-commit-check = pre-commit-hooks.lib.${system}.run {
+ src = ./.;
+ hooks = {
+ # Nix formatting
+ alejandra.enable = true;
+
+ # Toml formatting
+ taplo.enable = true;
+
+ # Rust formatting and linting
+ rustfmt = {
+ enable = true;
+ packageOverrides = {
+ cargo = toolchain;
+ rustfmt = toolchain;
+ };
+ };
+ clippy = {
+ enable = true;
+ packageOverrides = {
+ cargo = toolchain;
+ clippy = toolchain;
+ };
+ settings = {
+ denyWarnings = true;
+ };
+ };
+
+ # Spell checking
+ typos.enable = true;
+ };
+ };
+
+ devShells.default = pkgs.mkShell {
+ buildInputs = with pkgs;
+ [
+ mold
+ clang
+ just
+ ]
+ ++ libs
+ ++ [
+ toolchain
+ self.checks.${system}.pre-commit-check.enabledPackages
+ ];
+ LD_LIBRARY_PATH = lib.makeLibraryPath libs;
+ shellHook = ''
+ ${self.checks.${system}.pre-commit-check.shellHook}
+ '';
+ };
+ };
+ };
+}
A => input/day1/example +6 -0
@@ 1,6 @@
+3 4
+4 3
+2 5
+1 3
+3 9
+3 3
A => input/day1/input +1000 -0
@@ 1,1000 @@
+39687 54930
+86219 31559
+48536 73145
+19932 82178
+87646 97411
+18305 78515
+60437 30432
+35451 49981
+93478 61402
+19754 38933
+85455 20590
+82836 14896
+55217 89552
+11698 99229
+93753 84187
+93422 97415
+57366 97415
+97937 74337
+49478 74337
+14644 38161
+19399 13589
+74271 80973
+30811 43748
+39084 14139
+50012 35681
+26833 68646
+85916 94351
+48783 65976
+60349 37405
+48397 24524
+12784 96876
+26511 32005
+25828 50973
+41783 18470
+86788 84403
+52646 85455
+47960 55292
+33628 88834
+60975 32865
+18734 34272
+97411 13386
+98587 32005
+13899 55558
+83942 39621
+27222 72250
+92406 40726
+58334 43748
+57066 38522
+39164 54930
+41041 87903
+53063 31354
+41396 72724
+95245 79046
+83977 29994
+23525 23626
+28481 78774
+57089 88281
+95507 89601
+14606 37413
+83403 69108
+20870 65520
+52065 31711
+10688 43748
+14754 74862
+58940 92984
+34160 79046
+40229 15374
+19557 39621
+76326 14606
+18064 99891
+50829 29383
+24524 85455
+45230 19089
+89022 79046
+66250 51691
+90805 65372
+56019 50673
+67451 12866
+76068 65372
+77238 83243
+93710 65976
+79065 73391
+24363 74337
+29740 32931
+87834 79002
+30513 20720
+15378 30432
+13130 97438
+66810 70609
+98441 68294
+83594 50359
+43148 83382
+25005 37240
+98638 65372
+78319 50811
+90823 58614
+16089 93976
+14911 13087
+60443 12156
+94516 50973
+91753 26787
+15992 37046
+79270 50973
+67191 65372
+32268 35681
+41819 54930
+41351 69285
+44832 11020
+72750 91217
+34941 23646
+65976 65070
+56038 47570
+28753 81142
+63264 23646
+26145 88981
+71576 17123
+97331 79046
+22775 79740
+85844 94770
+25823 10501
+34176 91199
+45060 20266
+31332 25957
+32455 16146
+87120 19937
+73733 97415
+37954 51285
+28922 96517
+39972 32931
+30973 99605
+86546 62291
+80526 69673
+86070 73161
+55954 30432
+37437 34788
+63111 97415
+96362 88981
+75508 30398
+69428 81796
+28796 20675
+57288 32931
+73193 42247
+25130 51213
+38097 15664
+98834 26533
+32103 60744
+68331 13196
+22986 65372
+28918 65976
+27607 43147
+98022 83243
+39035 20720
+62361 42612
+78321 83243
+62399 15803
+84309 20526
+42350 39621
+51744 22556
+58919 92305
+37337 88981
+47722 83460
+29319 91248
+69603 85455
+56191 19231
+62286 73859
+28227 18100
+36024 83100
+60918 32611
+23022 88981
+38410 13292
+29383 92881
+18625 84889
+25141 26391
+69831 15803
+56740 18537
+26869 48559
+60352 24016
+45390 32931
+45676 55292
+69684 51183
+20234 15201
+58742 39621
+99779 17566
+61992 70009
+52853 15896
+46535 20590
+81327 20620
+75451 65976
+25891 91886
+78175 46303
+33500 61400
+78157 29280
+51091 31645
+73117 43748
+66382 70259
+59120 20590
+48683 38424
+21096 58463
+81257 48491
+30677 65122
+70554 61053
+12626 43309
+13513 74337
+71553 39621
+53798 20720
+48705 20590
+46863 35681
+90815 71503
+15964 69448
+68964 19189
+76668 55292
+64426 98722
+29505 73351
+33746 29460
+10038 84187
+48123 58056
+77274 43748
+29578 68732
+55816 65976
+18618 43748
+62734 31263
+12764 71426
+61615 18256
+44776 55292
+69008 44200
+69615 29383
+21562 80490
+41425 32594
+21356 55560
+28712 99731
+56355 55292
+11748 39388
+19994 41606
+10033 82834
+11253 97411
+14845 74337
+78797 23324
+66173 43748
+70836 75361
+59179 10501
+53947 35681
+84118 92551
+87855 85455
+62508 58746
+99196 43088
+93172 44793
+99062 76397
+77322 55292
+16386 74377
+95019 50973
+67124 32931
+23658 92851
+22040 24243
+20095 18432
+86545 53685
+94185 84851
+65351 50443
+43248 97411
+30440 89706
+74737 79046
+46947 71503
+80582 10501
+49951 40689
+67305 65372
+85943 39673
+26645 53881
+94034 35681
+69322 74264
+81573 74337
+85036 82011
+32378 89449
+72709 38642
+66311 30432
+14984 25526
+42649 24834
+91802 79129
+75402 23646
+39996 41604
+18325 29105
+61602 47315
+74612 54077
+15431 87294
+82611 37415
+30159 25725
+68269 50973
+64640 32005
+24359 73902
+66906 70478
+12361 96235
+72942 90254
+98451 20590
+59149 55292
+44917 85455
+22929 31273
+60258 50973
+63980 57267
+32828 71587
+51001 98441
+10733 55292
+20720 55900
+79366 88638
+61465 21535
+49575 23016
+78447 74337
+12815 89570
+12157 29383
+27474 83243
+95075 55673
+96642 20590
+29226 22801
+96829 87851
+84841 35759
+49793 65372
+13351 80850
+50977 23646
+50215 99614
+87295 35681
+98087 92194
+43530 98441
+29741 45244
+24141 55292
+67314 39621
+57310 87645
+20572 56180
+75549 65310
+33083 79046
+49934 50973
+16255 85455
+22048 74337
+67521 30432
+22178 32931
+40137 54930
+93021 33176
+90141 64438
+20161 30432
+31200 83204
+49277 71955
+15343 35290
+69746 97411
+94592 82043
+93759 97411
+42111 43395
+45727 50234
+71307 31990
+24277 79046
+10940 23668
+87027 65372
+77454 29383
+73569 20590
+32144 86307
+83494 35248
+86165 25280
+21035 33870
+51419 38933
+62394 65976
+20590 38491
+16178 16522
+32526 99622
+66974 94518
+24041 96291
+50807 97415
+36530 77854
+34288 98477
+25885 32931
+39957 39146
+36622 65372
+43748 56856
+22540 64266
+47812 25636
+60778 20520
+37116 73874
+74490 49028
+23646 57999
+10244 97415
+93378 69485
+92192 82321
+49671 47880
+40968 14606
+30997 75730
+44903 96764
+97415 35945
+42061 18761
+67473 32005
+71346 62789
+35117 38933
+68817 30432
+55081 30581
+63660 20730
+27470 41097
+85409 76643
+79664 57942
+59103 19889
+89854 85455
+34937 23469
+62589 71503
+31126 79046
+59987 17936
+41702 15768
+53158 89572
+47155 50973
+15410 66375
+33512 96295
+17682 24524
+85010 42666
+42326 71503
+74438 54930
+90691 88981
+24647 11015
+75856 26787
+10008 29383
+59249 95463
+61498 99412
+92390 58161
+98660 13452
+64740 97415
+42786 78023
+95159 44617
+88981 22058
+10814 89818
+82896 55292
+59582 74337
+36481 63656
+64320 84187
+78275 20590
+12031 97411
+55466 97411
+78361 32931
+27572 43748
+65372 53800
+25862 45484
+45103 24524
+46928 79046
+85030 55720
+88276 23748
+18649 19319
+35681 17984
+29111 20651
+94218 97415
+86252 38933
+93823 61400
+77315 74483
+29554 36566
+69304 32005
+67449 63281
+59720 30968
+97180 10501
+42054 96975
+84226 73716
+77336 97415
+95184 50973
+74680 79227
+44559 20266
+42923 89529
+23122 80745
+68282 79046
+18348 96777
+43175 77218
+47771 50919
+71875 31700
+51767 10501
+15666 77315
+47306 50973
+67340 24524
+39560 97411
+27302 71081
+22715 10711
+19262 35428
+30522 32931
+41704 85455
+69346 71001
+69691 20866
+39771 41097
+67926 78162
+33936 65976
+27443 41097
+71926 20590
+89325 87688
+95998 20724
+49871 36142
+18672 62700
+60268 10501
+95709 49926
+58557 70587
+86330 24463
+66612 55292
+63979 35681
+45966 26787
+30432 26787
+88832 43748
+16475 24524
+43091 50973
+91285 35681
+74407 71503
+74337 49897
+44472 42771
+51748 32931
+66315 42856
+70339 28495
+32919 97411
+34170 46975
+29144 84300
+68669 97411
+79046 96815
+68797 81914
+61355 48612
+66045 26787
+65345 61624
+34776 88918
+62024 45208
+22080 92268
+41658 29383
+40489 90276
+77414 91031
+87328 42581
+39847 29383
+62166 56210
+14946 97415
+46608 32931
+61626 97411
+68038 26110
+74304 24524
+33687 65027
+89997 29383
+71497 48576
+70649 20720
+75076 43748
+39550 57870
+42772 33596
+27314 43930
+52382 16823
+10501 32931
+60075 65372
+67162 62251
+18539 10501
+98602 39621
+86708 24677
+18832 39692
+34806 62896
+57052 88981
+26225 90413
+86466 77315
+22149 79085
+72545 38933
+61056 79046
+42425 79046
+18465 97415
+96275 26478
+93622 62612
+24920 61828
+76211 92315
+42390 25904
+22748 32005
+23429 11388
+28323 71503
+69320 61063
+39102 97714
+27448 32005
+60718 84165
+38364 82518
+65294 65372
+78308 27739
+71470 41212
+18756 33498
+21876 38933
+23964 17950
+63538 82294
+27576 19320
+11707 43748
+84686 20831
+26018 61400
+49866 33433
+76498 38933
+18202 35681
+32295 24256
+13631 32931
+82697 51213
+93416 51322
+33240 39621
+50664 24609
+24764 77315
+89632 68872
+30109 29018
+91551 83438
+61710 97411
+94996 54930
+58869 86341
+32931 79847
+83906 51213
+63729 89532
+92094 59179
+57957 15741
+14369 44761
+87984 43748
+73328 42459
+85008 58525
+57450 70925
+65808 43556
+20553 11393
+80030 43748
+24598 84187
+14926 86503
+63774 36452
+56586 29383
+42048 54930
+29688 83243
+81927 33315
+37463 73028
+44318 70491
+38022 64772
+40289 43748
+36192 95264
+34815 63383
+30912 49204
+29375 60846
+10954 67406
+20827 44437
+71373 82013
+55907 39621
+66557 97415
+20370 84187
+42450 29383
+47937 54930
+35114 76258
+50280 46068
+53360 87478
+52625 46035
+74506 23646
+78581 65372
+50670 41097
+67067 43748
+53047 91346
+28877 84369
+42353 97411
+71840 54233
+62376 27440
+53738 86424
+24879 52760
+69261 35681
+57133 64491
+33644 97411
+73635 32005
+12036 20590
+27599 31074
+41620 37578
+31518 39621
+43210 93438
+29331 39621
+80103 46896
+58324 86405
+72535 32976
+50973 39621
+19898 39789
+95111 74741
+62134 58215
+22738 92185
+85240 38472
+41403 44573
+10562 32005
+66230 19396
+66002 30432
+29925 18981
+86609 30432
+16196 20590
+26610 94216
+28817 24524
+64124 85455
+81667 67238
+49763 26547
+64284 29383
+62185 50068
+99896 16882
+46020 90218
+17194 35268
+74962 97415
+13420 33099
+16973 51937
+89651 43043
+67742 88988
+54231 39621
+41902 55292
+93241 82277
+53267 13313
+75234 75622
+89219 23646
+99065 93661
+23411 67647
+41648 75186
+78473 93028
+46849 26787
+96778 23661
+36339 84643
+66106 32005
+83602 19530
+60191 26202
+39157 38933
+75269 24524
+54146 77716
+64769 50973
+32005 65976
+95839 41098
+80529 20838
+30527 36612
+83243 65976
+58199 55292
+78364 93097
+15803 33060
+19540 81520
+24332 55715
+69804 14018
+89498 26787
+32922 55158
+51186 50973
+64371 59179
+67761 36282
+14931 65372
+33983 30208
+23532 99746
+60995 32005
+46968 33271
+71489 76548
+15532 56451
+60734 39621
+80923 84616
+55415 95600
+33838 97411
+38933 92991
+28270 15952
+64729 43748
+82909 41097
+21322 20447
+20606 32931
+20323 10923
+65612 72747
+42742 85455
+60541 15141
+69361 28920
+83643 78124
+33413 26942
+80131 64910
+60963 84167
+31622 20590
+76264 85208
+78435 48325
+64808 22279
+28784 75805
+84514 46617
+99920 39621
+64277 79046
+32066 65976
+61170 83000
+53590 24445
+75500 44994
+21399 74337
+57159 53312
+95725 45088
+47434 32005
+14728 20279
+86794 41097
+52400 97415
+64448 84187
+27278 10285
+54885 10894
+79570 20720
+85379 82557
+19497 60054
+10131 28282
+82510 72112
+37690 74278
+19278 55292
+28841 30432
+27287 99050
+32480 82634
+56252 20590
+77005 27163
+38978 77315
+12387 43748
+17737 29495
+55292 85455
+95579 20590
+60386 54930
+83024 43060
+43990 54930
+14130 10610
+97781 65608
+25377 27025
+10359 44055
+44237 75566
+30104 32005
+93883 46062
+28533 43292
+52211 50973
+28015 35681
+54979 23646
+59145 59518
+88731 93289
+92214 28192
+60194 65976
+96948 71503
+83445 85455
+44724 58215
+99575 77315
+59780 74337
+88198 69047
+67804 17472
+15309 77315
+63776 32005
+39191 93784
+88847 12410
+51336 18547
+67934 97415
+61623 75270
+30153 52371
+13866 84187
+13232 19867
+18107 32931
+24272 65976
+37532 57552
+74619 11064
+18266 66168
+69298 55431
+74422 24753
+83542 61400
+93767 78919
+70226 33845
+83460 67750
+30637 52438
+17147 51213
+47019 60841
+61400 96946
+99313 50492
+24905 49729
+64661 32931
+80464 42915
+59801 65976
+26787 88398
+30009 59179
+46714 50760
+85549 97411
+80405 14606
+90469 57491
+47988 57093
+54532 10501
+49943 20590
+77697 71503
+11487 99685
+41097 61400
+96136 98696
+65608 94443
+55729 71785
+64859 13167
+51213 97415
+95044 45340
+26875 41284
+20266 68008
+54279 10125
+49123 27746
+25659 97411
+71503 77315
+25042 15803
+85683 34351
+75203 87921
+15024 83243
+48884 23732
+20362 88981
+29757 33017
+69591 83341
+52463 20266
+96531 50973
+18691 82070
+38982 10738
+46845 53716
+43757 97415
+59287 30432
+53671 87058
+71592 73972
+15612 13840
+31062 83351
+27714 30432
+81451 91637
+83692 24524
+17667 19315
+38165 99318
+31407 50973
+54602 32944
+16418 62441
+24549 83243
+68171 97415
+45107 66287
+85000 77293
+52279 50973
+39804 88981
+54930 89838
+33435 55541
+35192 24621
+28963 61285
+62401 47165
+62057 35923
+66086 20060
+68558 43071
+64279 11503
+53866 28743
+53322 43781
+57423 30491
+84187 62562
+36345 20720
+14838 82939
+66499 32457
+12383 43748
+49461 57729
+63604 83243
+70558 87459
+25392 69359
+76916 65373
+92341 76150
+35379 65372
+76956 26702
+95342 21946
+70320 20266
+69676 49315
+61564 54930
+87659 27359
+76459 14606
+58765 35234
+60496 10501
+95443 56583
+23163 54736
+42578 96214
+35408 28339
+73211 38245
+19253 45584
+81387 77205
+60736 94989
+93733 39621
+35524 20266
+10497 11300
+82104 39339
+63189 79046
+69699 13319
+64848 21528
+79082 32931
+25166 97415
+67709 72646
+89006 61400
+31258 20322
+78044 39621
+28810 14074
+85541 99495
+25783 78712
+84160 85455
+60869 68898
+15908 91740
+21392 98478
+91823 94915
+68112 93339
+68487 50503
+79369 77802
+33236 96238
+53085 59514
+25758 50973
+95806 71503
+79198 78066
+87996 54816
+11943 39621
+98740 65372
+63599 54930
+30758 61133
+78768 47891
+29026 30432
+62476 91148
+19193 10501
+47322 14810
+30951 43985
+42954 61631
+32520 95242
+31248 55278
+58121 97415
+30540 55292
+35353 29383
+72450 97411
+69146 74337
+87152 76785
+31122 93490
+58215 43748
+92645 55292
+12395 71311
+88681 18719
+37459 27744
+36993 84187
+48597 39621
+94499 50619
+68261 90287
+35126 73663
+95513 97411
+73472 38933
+28325 29796
+83597 72689
+12914 79531
+39621 90125
+10029 95431
+85400 15291
A => justfile +8 -0
@@ 1,8 @@
+_default:
+ just --list
+
+example DAY:
+ cargo run day{{DAY}} -i input/day{{DAY}}/example
+
+solve DAY:
+ cargo run day{{DAY}} -i input/day{{DAY}}/input
A => rust-toolchain.toml +2 -0
@@ 1,2 @@
+[toolchain]
+channel = "1.83.0"
A => src/day1/mod.rs +58 -0
@@ 1,58 @@
+use std::{
+ fs::File,
+ io::{BufRead, BufReader},
+ path::Path,
+};
+
+pub fn solve(input: &Path) -> anyhow::Result<()> {
+ println!("part one: {}", part_one(input)?);
+ println!("part two: {}", part_two(input)?);
+
+ Ok(())
+}
+
+fn part_one(input: &Path) -> anyhow::Result<i32> {
+ let reader = BufReader::new(File::open(input)?);
+
+ let mut first: Vec<i32> = vec![];
+ let mut second: Vec<i32> = vec![];
+ for line in reader.lines() {
+ let line = line?;
+ let mut numbers = line.split_whitespace();
+ first.push(numbers.next().unwrap().parse()?);
+ second.push(numbers.next().unwrap().parse()?);
+ }
+ first.sort();
+ second.sort();
+ let mut answer = 0;
+ for (i, f) in first.into_iter().enumerate() {
+ answer += (f - second[i]).abs();
+ }
+
+ Ok(answer)
+}
+
+fn part_two(input: &Path) -> anyhow::Result<i32> {
+ let reader = BufReader::new(File::open(input)?);
+
+ let mut first: Vec<i32> = vec![];
+ let mut second: Vec<i32> = vec![];
+ for line in reader.lines() {
+ let line = line?;
+ let mut numbers = line.split_whitespace();
+ first.push(numbers.next().unwrap().parse()?);
+ second.push(numbers.next().unwrap().parse()?);
+ }
+ let mut answer = 0;
+ for f in first {
+ let amount = second
+ .clone()
+ .into_iter()
+ .filter(|&s| s == f)
+ .collect::<Vec<i32>>()
+ .len();
+ answer += f * amount as i32;
+ }
+
+ Ok(answer)
+}
A => src/main.rs +31 -0
@@ 1,31 @@
+use std::path::PathBuf;
+
+use clap::{Parser, Subcommand};
+
+mod day1;
+
+#[derive(Parser)]
+struct Args {
+ #[command(subcommand)]
+ day: DayArgs,
+}
+
+#[derive(Subcommand)]
+enum DayArgs {
+ Day1 {
+ #[arg(short, default_value = "./input/day1/example")]
+ input: PathBuf,
+ },
+}
+
+fn main() -> anyhow::Result<()> {
+ let args = Args::parse();
+
+ match args.day {
+ DayArgs::Day1 { input } => {
+ day1::solve(&input)?;
+ }
+ }
+
+ Ok(())
+}