commit 65cf6c364a7ccbc94a1ca449d4ca45c36464899a Author: joshashtondev Date: Tue Dec 1 20:27:56 2026 -0700 day 01 - 2026 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..75e92a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +target +.direnv diff --git a/2026/.envrc b/2026/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/2026/.envrc @@ -0,0 +1 @@ +use flake diff --git a/2026/day-01/Cargo.lock b/2026/day-01/Cargo.lock new file mode 100644 index 0000000..6e11d14 --- /dev/null +++ b/2026/day-01/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "day-01" +version = "0.1.0" diff --git a/2026/day-01/Cargo.toml b/2026/day-01/Cargo.toml new file mode 100644 index 0000000..c43f1c8 --- /dev/null +++ b/2026/day-01/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "day-01" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/2026/day-01/rsrc/day-01/input.txt b/2026/day-01/rsrc/day-01/input.txt new file mode 100644 index 0000000..6192a7e --- /dev/null +++ b/2026/day-01/rsrc/day-01/input.txt @@ -0,0 +1,2001 @@ +645 +134 +402 +943 +198 +340 +550 +192 +935 +991 +524 +595 +159 +213 +520 +432 +887 +185 +356 +540 +754 +133 +784 +887 +574 +844 +939 +283 +684 +276 +409 +162 +176 +710 +177 +390 +714 +799 +614 +568 +698 +696 +681 +806 +838 +381 +606 +335 +127 +810 +959 +477 +184 +151 +269 +432 +914 +855 +586 +415 +861 +912 +863 +701 +122 +688 +921 +655 +488 +701 +946 +684 +767 +393 +455 +292 +879 +790 +731 +976 +913 +696 +895 +603 +521 +638 +530 +121 +393 +959 +257 +692 +308 +651 +923 +628 +781 +101 +229 +540 +621 +622 +230 +207 +147 +536 +615 +823 +467 +282 +990 +943 +663 +994 +795 +618 +161 +923 +572 +250 +561 +750 +536 +385 +675 +840 +822 +945 +204 +618 +286 +375 +691 +934 +112 +169 +766 +834 +661 +334 +312 +721 +623 +853 +356 +741 +101 +699 +913 +663 +334 +262 +899 +439 +621 +925 +481 +427 +398 +934 +639 +426 +277 +221 +889 +672 +573 +600 +996 +430 +402 +868 +393 +553 +180 +576 +445 +257 +892 +898 +224 +806 +459 +710 +477 +593 +703 +757 +946 +516 +106 +118 +851 +634 +949 +421 +616 +550 +563 +572 +682 +954 +273 +486 +183 +945 +695 +928 +492 +265 +774 +149 +637 +753 +719 +208 +747 +691 +743 +695 +824 +436 +553 +630 +158 +356 +535 +265 +234 +787 +659 +729 +462 +941 +767 +704 +429 +207 +836 +904 +976 +491 +904 +409 +899 +516 +198 +397 +402 +648 +377 +377 +768 +443 +708 +452 +668 +956 +851 +439 +634 +223 +672 +750 +922 +555 +645 +662 +781 +105 +161 +121 +747 +451 +185 +750 +691 +649 +524 +854 +843 +353 +623 +163 +385 +818 +800 +750 +221 +168 +628 +680 +612 +451 +879 +824 +702 +409 +381 +147 +564 +173 +511 +711 +708 +328 +480 +517 +129 +504 +614 +732 +998 +687 +227 +841 +474 +966 +671 +334 +502 +440 +256 +744 +336 +631 +736 +743 +541 +568 +390 +649 +556 +324 +112 +144 +679 +188 +274 +221 +578 +207 +869 +853 +713 +302 +285 +578 +637 +223 +800 +546 +922 +985 +520 +726 +462 +242 +981 +822 +587 +831 +615 +198 +948 +643 +602 +119 +159 +578 +703 +292 +713 +930 +835 +420 +898 +161 +986 +438 +326 +757 +417 +745 +480 +800 +975 +941 +256 +966 +909 +505 +346 +118 +339 +827 +693 +355 +909 +806 +419 +481 +117 +741 +824 +726 +368 +757 +561 +239 +336 +561 +353 +405 +106 +670 +123 +736 +524 +156 +795 +142 +861 +829 +355 +226 +229 +174 +837 +274 +997 +626 +740 +315 +417 +467 +486 +698 +162 +235 +798 +186 +553 +801 +599 +576 +485 +839 +668 +345 +419 +102 +599 +200 +499 +993 +835 +122 +169 +833 +943 +397 +368 +365 +235 +787 +993 +314 +535 +127 +184 +550 +117 +285 +486 +610 +885 +633 +489 +287 +251 +717 +805 +444 +746 +615 +766 +296 +675 +729 +930 +367 +587 +115 +934 +536 +541 +318 +622 +710 +690 +103 +878 +364 +489 +422 +124 +692 +452 +277 +994 +676 +762 +637 +250 +649 +112 +413 +949 +958 +488 +904 +125 +263 +823 +245 +103 +456 +328 +686 +195 +921 +283 +651 +633 +690 +990 +557 +120 +442 +394 +786 +455 +282 +565 +801 +438 +409 +442 +696 +163 +819 +445 +243 +744 +602 +588 +289 +571 +861 +449 +502 +597 +889 +511 +944 +682 +213 +346 +829 +801 +925 +120 +100 +405 +491 +768 +652 +197 +231 +823 +597 +570 +692 +421 +462 +796 +123 +823 +262 +208 +639 +456 +190 +654 +694 +124 +837 +460 +773 +541 +102 +841 +744 +706 +686 +427 +798 +883 +353 +504 +124 +966 +302 +340 +747 +629 +250 +237 +433 +524 +502 +771 +687 +339 +129 +105 +831 +459 +806 +267 +420 +787 +616 +638 +370 +570 +497 +415 +752 +328 +423 +394 +745 +980 +935 +997 +736 +701 +360 +515 +969 +315 +174 +619 +833 +741 +463 +200 +835 +268 +150 +820 +239 +364 +183 +676 +645 +719 +810 +627 +517 +324 +505 +265 +487 +898 +399 +869 +452 +247 +631 +581 +648 +228 +770 +149 +166 +897 +329 +644 +463 +431 +649 +195 +567 +350 +854 +360 +632 +545 +112 +655 +198 +115 +924 +110 +726 +840 +229 +811 +322 +549 +119 +796 +552 +885 +398 +370 +717 +570 +145 +631 +502 +701 +185 +540 +296 +777 +861 +568 +705 +499 +442 +328 +184 +923 +200 +105 +459 +574 +432 +711 +652 +314 +163 +335 +870 +619 +224 +762 +675 +443 +621 +959 +246 +184 +970 +747 +965 +914 +346 +535 +737 +610 +161 +360 +536 +384 +127 +231 +237 +488 +892 +853 +953 +576 +978 +842 +160 +263 +367 +582 +583 +368 +863 +924 +682 +679 +399 +820 +867 +172 +807 +370 +534 +228 +855 +735 +932 +856 +530 +958 +760 +753 +899 +350 +753 +139 +646 +429 +825 +991 +688 +603 +365 +568 +684 +652 +766 +794 +719 +296 +732 +868 +833 +545 +655 +545 +670 +887 +573 +713 +426 +227 +345 +129 +463 +694 +663 +230 +643 +555 +287 +770 +701 +699 +969 +687 +939 +521 +433 +504 +619 +515 +889 +657 +100 +417 +370 +516 +729 +859 +567 +885 +638 +786 +635 +302 +263 +661 +691 +346 +839 +593 +277 +705 +597 +310 +945 +134 +635 +100 +784 +630 +445 +818 +672 +680 +824 +240 +869 +868 +139 +704 +243 +774 +954 +773 +708 +436 +924 +286 +499 +923 +246 +186 +695 +587 +335 +883 +811 +197 +614 +721 +337 +405 +757 +867 +825 +204 +704 +626 +243 +949 +482 +101 +121 +228 +117 +583 +945 +126 +757 +440 +150 +736 +375 +570 +820 +442 +662 +142 +142 +255 +824 +899 +266 +147 +602 +490 +118 +448 +262 +123 +581 +539 +318 +891 +586 +639 +431 +101 +870 +639 +176 +550 +732 +117 +694 +668 +356 +985 +771 +467 +283 +208 +679 +450 +239 +711 +422 +901 +262 +145 +652 +909 +553 +372 +350 +407 +928 +399 +861 +774 +384 +127 +368 +235 +810 +227 +562 +161 +948 +285 +659 +676 +681 +312 +863 +177 +135 +717 +563 +593 +119 +224 +504 +119 +811 +147 +335 +991 +762 +120 +698 +274 +960 +337 +571 +535 +505 +451 +944 +969 +882 +714 +534 +629 +629 +921 +150 +292 +357 +390 +681 +972 +603 +891 +482 +288 +133 +200 +329 +481 +269 +308 +754 +430 +398 +671 +978 +644 +522 +904 +941 +100 +794 +172 +743 +618 +397 +754 +409 +746 +405 +196 +971 +922 +908 +481 +480 +492 +142 +110 +853 +599 +928 +153 +247 +627 +670 +421 +181 +460 +520 +556 +627 +455 +913 +859 +830 +251 +429 +289 +288 +573 +870 +177 +372 +981 +994 +768 +433 +708 +632 +889 +606 +228 +844 +134 +632 +645 +790 +924 +729 +117 +711 +693 +173 +192 +398 +898 +851 +655 +440 +822 +422 +831 +576 +583 +174 +308 +796 +485 +394 +439 +932 +539 +546 +630 +326 +431 +576 +738 +786 +822 +242 +292 +223 +737 +829 +541 +202 +546 +302 +226 +181 +777 +993 +269 +621 +635 +804 +616 +267 +474 +377 +162 +355 +804 +596 +546 +286 +998 +753 +837 +869 +439 +596 +421 +572 +631 +786 +810 +477 +760 +909 +149 +834 +682 +714 +158 +986 +497 +646 +978 +981 +737 +417 +859 +485 +859 +322 +925 +897 +810 +566 +566 +676 +828 +202 +597 +491 +337 +283 +641 +842 +202 +998 +694 +822 +565 +615 +837 +805 +344 +649 +635 +671 +670 +996 +163 +310 +539 +407 +825 +282 +566 +273 +622 +553 +103 +100 +682 +996 +535 +704 +825 +172 +159 +162 +245 +282 +841 +904 +632 +836 +542 +206 +595 +655 +106 +930 +540 +689 +796 +618 +834 +948 +630 +156 +390 +913 +467 +166 +232 +432 +367 +557 +315 +698 +842 +856 +135 +310 +721 +960 +169 +668 +153 +932 +463 +781 +643 +641 +380 +699 +208 +188 +385 +882 +970 +370 +176 +449 +144 +455 +240 +699 +944 +970 +360 +462 +443 +811 +208 +615 +482 +499 +105 +662 +829 +353 +564 +149 +652 +901 +186 +710 +398 +935 +536 +427 +671 +717 +680 +448 +407 +190 +684 +958 +662 +908 +990 +339 +805 +522 +318 +361 +122 +185 +204 +798 +511 +975 +120 +197 +633 +679 +257 +542 +806 +539 +357 +959 +372 +504 +153 +346 +242 +895 +267 +337 +794 +492 +444 +994 +668 +350 +939 +922 +381 +562 +126 +956 +823 +520 +732 +237 +139 +168 +340 +835 +329 +960 +357 +741 +644 +693 +158 +828 +522 +344 +991 +511 +630 +427 +771 +427 +918 +166 +439 +771 +768 +637 +882 +262 +173 +891 +460 +345 +273 +474 +843 +361 +255 +231 +490 +360 +285 +901 +133 +221 +353 +934 +918 +274 +828 +953 +324 +738 +246 +460 +489 +885 +648 +721 +941 +930 +335 +671 +563 +593 +689 +804 +102 +417 +555 +838 +251 +144 +886 +965 +326 +517 +177 +587 +970 +234 +226 +405 +266 +555 +557 +684 +918 +255 +921 +312 +633 +487 +156 +619 +456 +172 +179 +221 +288 +192 +836 +377 +276 +825 +878 +232 +619 +752 +444 +606 +840 +364 +679 +663 +206 +206 +839 +838 +423 +924 +126 +448 +686 +922 +616 +336 +517 +998 +746 +830 +499 +781 +450 +702 +482 +795 +855 +634 +255 +180 +491 +885 +273 +276 +456 +837 +784 +790 +318 +183 +795 +567 +681 +687 +646 +710 +972 +226 +643 +119 +719 +976 +151 +998 +659 +767 +399 +949 +738 +901 +181 +407 +339 +752 +834 +661 +450 +232 +168 +124 +230 +784 +975 +197 +731 +134 +654 +345 +972 +449 +886 +552 +851 +361 +571 +195 +784 +115 +166 +367 +423 +879 +768 +956 +245 +380 +268 +928 +179 +502 +103 +807 +886 +110 +314 +798 +179 +399 +735 +440 +415 +946 +195 +912 +568 +794 +628 +690 +106 +455 +741 +930 +180 +853 +889 +269 +740 +228 +421 +892 +612 +986 +118 +566 +878 +960 +807 +713 +843 +314 +192 +451 +422 +308 +774 +946 +240 +627 +326 +582 +596 +941 +706 +488 +367 +229 +265 +705 +487 +737 +344 +489 +207 +162 +186 +459 +854 +654 +820 +737 +737 +708 +459 +623 +235 +996 +586 +340 +732 +644 +172 +188 +959 +106 +158 +450 +226 +971 +932 +419 +490 +746 +595 +790 +462 +657 +634 +914 +805 +430 +633 +990 +438 +516 +482 +628 +432 +805 +571 +829 +415 +583 +867 +574 +474 +207 +811 +705 +593 +420 +612 +490 +240 +932 +781 +552 +120 +375 +126 +289 +699 +402 +681 +234 +958 +690 +628 +565 +753 +481 +886 +969 +202 +657 +606 +190 +581 +745 +597 +151 +840 +242 +289 +570 +176 +595 +831 +356 +680 +413 +883 +277 +247 +840 +496 +738 +256 +488 +562 +524 +675 +582 +801 +240 +122 +521 +564 +160 +921 +393 +843 +688 +445 +794 +555 +431 +588 +160 +632 +420 +595 +818 +474 +444 +385 +661 +232 +863 +176 +689 +796 +777 +581 +542 +556 +985 +196 +515 +345 +419 +934 +129 +334 +954 +422 +195 +737 +582 +622 +713 +830 +703 +980 +268 +534 +166 +735 +196 +477 +563 +430 +150 +752 +287 +745 +588 +901 +545 +975 +269 +190 +232 +760 +440 +887 +675 +980 +556 +714 +627 +965 +908 +651 +539 +192 +731 +541 +159 +120 +276 +463 +121 +740 +545 +550 +308 +133 +213 +744 +204 +994 +908 +105 +935 +694 +198 +986 +160 +621 +180 +112 +671 +985 +413 +948 +918 +381 +286 +629 +384 +385 +125 +442 +312 +565 +985 +953 +174 +101 +986 +626 +600 +549 +380 +844 +572 +638 +118 +610 +735 +102 +819 +243 +160 +991 +583 +925 +581 +102 +702 +334 +971 +735 +135 +954 +736 +530 +773 +497 +895 +444 +150 +672 +145 +237 +286 +641 +180 +971 +747 +115 +762 +562 +686 +600 +827 +754 +868 +350 +976 +827 +322 +773 +190 +125 +953 +314 +151 +426 +859 +326 +912 +925 +954 +622 +159 +213 +445 +288 +549 +436 +273 +690 +639 +492 +127 +819 +856 +676 +283 +663 +586 +200 +689 +266 +828 +870 +897 +706 +365 +997 diff --git a/2026/day-01/rsrc/day-01/test-input.txt b/2026/day-01/rsrc/day-01/test-input.txt new file mode 100644 index 0000000..97ab6e7 --- /dev/null +++ b/2026/day-01/rsrc/day-01/test-input.txt @@ -0,0 +1,21 @@ +57 +57 +55 +57 +76 +78 +57 +45 +43 +78 +43 +76 +43 +78 +57 +45 +57 +76 +43 +43 +76 diff --git a/2026/day-01/src/main.rs b/2026/day-01/src/main.rs new file mode 100644 index 0000000..4490ba4 --- /dev/null +++ b/2026/day-01/src/main.rs @@ -0,0 +1,77 @@ +use std::{ + collections::{ + BinaryHeap, + HashMap + }, + env, + fs::File, + io::{ + self, + BufRead, + BufReader + }, + cmp::Reverse +}; + +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] +struct ID { + count: u32, + val: u32 +} + +fn main() -> io::Result<()> { + let args: Vec = env::args().collect(); + + if args.len() < 2 { + eprintln!("usage: {} ", args[0]); + std::process::exit(1); + } + + let f = File::open(&args[1])?; + let reader = BufReader::new(f); + let mut counts: HashMap = HashMap::new(); + + for line in reader.lines() { + let line = line?; + let line = line.trim(); + + if line.is_empty() { + continue; + } + + let val: u32 = line.parse().expect("not a valid u16"); + *counts.entry(val).or_insert(0) += 1; + } + + let mut max_heap: BinaryHeap = counts + .clone() + .into_iter() + .map(|(val, count)| ID { count, val }) + .collect(); + + let mut max_total: u32 = 1; + + for _ in 0..3 { + if let Some(id) = max_heap.pop() { + max_total = max_total * id.val; + } + } + + let mut min_heap: BinaryHeap> = counts + .clone() + .into_iter() + .map(|(val, count)| Reverse(ID { count, val })) + .collect(); + + let mut min_total: u32 = 1; + + for _ in 0..3 { + if let Some(Reverse(id)) = min_heap.pop() { + min_total = min_total * id.val; + } + } + + println!("Part One: {}\nPart Two: {}", max_total, min_total); + + Ok(()) +} diff --git a/2026/flake.lock b/2026/flake.lock new file mode 100644 index 0000000..c43c772 --- /dev/null +++ b/2026/flake.lock @@ -0,0 +1,96 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1790185690, + "narHash": "sha256-xJ+X4hBtOcAFGBOe5nAMyMUeF9foJBmIOu3NjBqBycU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4975466d324710c576dc11ad614684e6bd8cad8e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1790234952, + "narHash": "sha256-tjQa1vDoHJir4lasZTakz/xgmsfB6SRjeQqaIbefFOk=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "ed34466c59b766481248959a21a6e46cf0c60468", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/2026/flake.nix b/2026/flake.nix new file mode 100644 index 0000000..1c92624 --- /dev/null +++ b/2026/flake.nix @@ -0,0 +1,46 @@ +{ + description = "A reproducible Rust development environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay.url = "github:oxalica/rust-overlay"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ (import rust-overlay) ]; + }; + + # Choose your preferred Rust toolchain (e.g., stable, nightly, or specific version) + rustToolchain = pkgs.rust-bin.stable.latest.default.override { + extensions = [ "rust-src" "rust-analyzer" ]; + }; + in + { + devShells.default = pkgs.mkShell { + # Tools available in the shell environment. rustToolchain includes rust-analyzer, + # so any Neovim config (e.g. rustaceanvim) picks it up automatically via PATH. + packages = [ + rustToolchain + pkgs.cargo-watch # Optional but highly useful utility + ]; + + # System libraries and build dependencies frequently needed by Rust crates + buildInputs = with pkgs; [ + openssl + pkg-config + ]; + + # Environment variables required by Rust tooling + env = { + RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library"; + RUST_BACKTRACE = "1"; + }; + }; + } + ); +}