diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..82b2b9e --- /dev/null +++ b/.envrc @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# the shebang is ignored, but nice for editors + +if type -P lorri &>/dev/null; then + eval "$(lorri direnv)" +else + echo 'while direnv evaluated .envrc, could not find the command "lorri" [https://github.com/nix-community/lorri]' + use nix +fi diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8a6b5a6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +2024/data/*/*.run \ No newline at end of file diff --git a/2024/Cargo.toml b/2024/Cargo.toml new file mode 100644 index 0000000..ed83346 --- /dev/null +++ b/2024/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "aoc2024" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow = "1.0.93" +code-timing-macros = { version = "0.0.5", features = ["release"] } +const_format = "0.2.33" +itertools = "0.13.0" +regex = "1.11.1" +clap = { version = "4.5.21", features = ["derive", "cargo"] } +colored-diff = "0.2.3" +thiserror = "2.0.3" \ No newline at end of file diff --git a/2024/data/01/1.in b/2024/data/01/1.in new file mode 100644 index 0000000..dfca0b1 --- /dev/null +++ b/2024/data/01/1.in @@ -0,0 +1,6 @@ +3 4 +4 3 +2 5 +1 3 +3 9 +3 3 \ No newline at end of file diff --git a/2024/data/01/1.out b/2024/data/01/1.out new file mode 100644 index 0000000..9d60796 --- /dev/null +++ b/2024/data/01/1.out @@ -0,0 +1 @@ +11 \ No newline at end of file diff --git a/2024/data/01/2.in b/2024/data/01/2.in new file mode 100644 index 0000000..fe669c4 --- /dev/null +++ b/2024/data/01/2.in @@ -0,0 +1,1000 @@ +56208 95668 +52621 74203 +95252 33335 +79799 26047 +88005 37435 +61887 93836 +48454 95821 +62543 40154 +68631 73255 +76702 79056 +70838 34466 +18680 46550 +51787 55754 +37646 48228 +85603 29306 +37768 75105 +90135 21612 +35469 74470 +21245 49622 +18699 49193 +21078 61415 +10873 95775 +91781 60483 +56840 42667 +81094 12954 +71762 61434 +64670 22232 +33536 77827 +24607 75889 +37829 78341 +36203 82413 +31747 95700 +22170 79056 +28403 89045 +82265 37081 +10713 74405 +76191 43205 +99737 87526 +75120 72550 +82607 40971 +81396 47693 +11533 39908 +21138 40655 +97567 42427 +11179 89506 +19548 50064 +43080 93836 +90155 37743 +21664 58398 +90621 89990 +52392 94519 +82246 62358 +14857 73475 +56878 69951 +48921 56211 +49545 83117 +84329 12955 +71390 48442 +27461 28450 +94969 86731 +32344 14652 +89304 37435 +61343 61730 +38097 85797 +21480 31806 +79330 58398 +29803 73475 +83903 58398 +82961 37081 +19048 16800 +46338 45021 +65120 97811 +94574 18471 +43129 37435 +80135 20553 +13860 30053 +23228 37081 +75373 99812 +72438 43358 +62029 81330 +46550 11995 +86921 92694 +34790 20959 +98862 85030 +82648 53872 +23156 43559 +86507 43025 +78535 78226 +86410 58158 +23699 18312 +43083 25346 +69925 11280 +93761 82246 +31314 38097 +31775 47098 +50720 24867 +59647 66769 +95275 17550 +12756 82744 +93464 99949 +50801 55400 +12063 60335 +10930 12955 +96820 63957 +51672 40727 +35874 40727 +23608 79584 +94056 80438 +46387 50916 +34304 37081 +83311 93836 +25295 43512 +17263 63763 +70673 30357 +68716 11280 +52238 27269 +99670 49467 +50516 93196 +84006 78719 +61795 33177 +43228 87640 +77557 99949 +98130 64716 +96939 61786 +95849 79056 +16209 89990 +65420 44437 +94486 11280 +66223 99949 +43524 86363 +62859 61786 +90225 84321 +88954 98335 +75285 17907 +38457 73475 +42857 24650 +10995 32077 +91376 57464 +77255 90595 +89361 86284 +59270 46550 +71756 57794 +87966 17022 +58398 55419 +96091 37435 +17150 87526 +39389 12196 +76990 67087 +61924 34998 +95291 73475 +50147 84321 +53391 84401 +36506 93836 +52291 27344 +12731 50538 +60534 89078 +79539 10368 +56787 99949 +54143 40727 +98095 75373 +30744 52795 +12926 38097 +51613 50801 +36198 65515 +28401 27065 +56046 78440 +70329 71912 +95114 36977 +60740 47082 +56549 11280 +57725 26874 +56639 89045 +79567 29741 +94022 76570 +96358 90832 +12302 95795 +76023 82246 +15612 97271 +17185 90595 +46709 45432 +13154 46550 +88519 43458 +32560 90478 +65035 71620 +92462 61237 +69416 79584 +35688 21793 +28438 39240 +82325 27813 +78531 84321 +24899 36148 +85012 89990 +23508 67634 +66264 60161 +66503 38477 +15986 91668 +79146 63922 +37435 85030 +62752 85977 +26512 81606 +40841 82246 +46251 73475 +34026 19249 +50440 41947 +76774 11280 +22007 60880 +94909 87526 +58404 84321 +75320 18175 +76222 89990 +91724 15431 +48733 37574 +36629 12879 +58515 21379 +12471 45395 +37709 79056 +14932 47109 +98634 80670 +97279 38097 +96785 84321 +12591 89556 +36934 61786 +41593 32076 +78262 38097 +60695 50941 +79770 93836 +41948 58398 +84058 63922 +35466 34206 +99842 86919 +57631 53042 +22167 33022 +61786 68147 +69070 89045 +30553 48228 +96972 46550 +49251 79584 +50994 75840 +91178 59794 +29903 18646 +92270 63922 +50470 19887 +68328 87526 +87788 29501 +56579 59667 +23154 37081 +29012 69142 +24751 89990 +12191 38097 +14613 62616 +88157 75476 +78319 74115 +57573 37081 +49634 88296 +80779 23920 +58363 45944 +38626 23891 +44119 43477 +87012 92308 +94285 19887 +47957 58398 +98671 73475 +80957 90536 +75724 97254 +55207 34449 +26929 46570 +88177 67524 +42538 87526 +60062 34610 +31875 89453 +84401 51230 +30370 37435 +77609 26508 +54400 89045 +16998 76877 +53993 49621 +80345 11280 +33089 83000 +59754 54338 +10070 58398 +79056 47218 +38998 94596 +78946 93836 +17022 58398 +26488 96876 +29505 48228 +87585 84630 +11881 50840 +34065 89196 +92780 57959 +84213 19887 +89873 64164 +88432 76456 +27932 48228 +75295 51234 +87532 48228 +89045 79056 +90024 40848 +83717 70022 +44095 35548 +61389 31672 +45153 80712 +53642 46743 +79895 27572 +62353 63922 +31718 43553 +47638 16679 +68079 37435 +99980 82246 +28989 53198 +55315 72011 +39285 57048 +63939 79056 +79274 44485 +67372 46550 +37081 89990 +90006 46550 +78226 14583 +49740 39212 +57801 58398 +99700 89990 +20514 78226 +74207 90650 +30895 37435 +45690 48228 +59599 95569 +36570 43919 +27098 46550 +23232 58398 +64885 62096 +85030 17022 +91242 68818 +32735 79056 +84321 35330 +15556 73475 +65535 20996 +46287 47868 +72870 88715 +26102 28963 +53627 60988 +24886 17144 +96189 76191 +24759 45636 +98950 93836 +47061 90595 +74001 11280 +91701 50701 +35581 79056 +55474 50020 +39955 95451 +16183 78226 +76584 61285 +22474 97165 +23396 37435 +71483 50801 +94355 26883 +16187 82246 +48892 19971 +78206 44272 +90897 53164 +60606 54389 +15976 30489 +64132 87526 +30030 56758 +58524 78226 +37832 38097 +78244 99949 +10124 28222 +45015 95384 +98771 10124 +69753 82069 +71588 56590 +39250 55040 +60302 75373 +44720 75373 +49715 89857 +17921 63358 +20595 41212 +71304 86278 +52931 42672 +12734 79056 +96838 51840 +69950 91553 +20134 46460 +44631 57523 +21834 82246 +87705 67785 +67003 90674 +57615 46550 +24713 27095 +92252 37081 +69531 40818 +95550 98970 +69979 52208 +86183 56378 +97271 66222 +34116 56073 +61862 26938 +69230 60312 +39386 73475 +91297 27731 +91115 71904 +65373 32930 +22264 84534 +42510 24914 +31022 11750 +79868 79584 +52225 11280 +81993 22693 +90622 29200 +10788 36850 +19596 74840 +18745 89990 +95360 48049 +37314 40727 +43291 88941 +16658 42023 +42096 91462 +35810 67282 +60361 64835 +92458 79056 +75435 68039 +28125 44179 +59855 53140 +77935 17022 +54641 63922 +38395 79056 +57487 60560 +28437 42839 +70988 11280 +71731 44391 +71274 97823 +26290 50801 +44854 28186 +48594 90871 +77287 73475 +65614 84401 +15083 12542 +46738 84321 +97269 92183 +70388 79584 +43702 50801 +68959 40727 +85936 67896 +66276 61786 +46788 79046 +75138 51794 +67218 16350 +84121 37435 +85923 46550 +27696 64738 +33242 97663 +53268 90595 +74163 13720 +35519 37435 +95673 76504 +75926 50898 +31828 46367 +13255 34762 +91251 19661 +35165 60459 +89359 57486 +56104 68802 +23120 10446 +27928 94429 +13036 87135 +68217 89045 +90595 77093 +64564 19604 +20580 38456 +95473 99949 +23762 19970 +94918 49478 +95915 73475 +43165 21655 +28604 10124 +77991 89045 +69168 12955 +67281 36803 +63168 34514 +54261 92874 +43629 11280 +58472 56533 +87513 85394 +78278 38097 +27186 53704 +12183 15651 +85071 34888 +74115 71810 +38589 42387 +59858 58282 +81623 50530 +18220 40720 +80203 37435 +25112 95576 +27487 51328 +52735 36378 +57441 83458 +16583 74359 +68008 88649 +93205 93836 +29428 76277 +63669 73090 +27809 91190 +71814 87028 +36345 69002 +19141 71868 +85043 10124 +35017 38242 +72320 53921 +66740 17022 +28399 78733 +22592 81140 +30299 45195 +34919 40727 +19792 89045 +25687 93836 +83082 90916 +40314 82874 +80873 63922 +21542 11066 +55959 94833 +77334 37081 +19353 21529 +19186 73475 +34259 95072 +13064 74519 +41193 49662 +55457 72223 +16381 65670 +50435 19770 +50032 50801 +49806 46550 +18336 37435 +13333 90595 +90334 19267 +60180 82246 +93184 62302 +74440 26507 +63011 87526 +40458 91304 +23721 57800 +63922 17206 +95151 38097 +51880 98112 +20539 54229 +93904 62420 +72851 46550 +42399 61786 +99078 63519 +12254 84321 +10577 44243 +46056 37435 +51235 39472 +50954 12660 +77199 56517 +18283 63922 +52859 87526 +15246 98536 +93836 97622 +49522 88978 +73549 40727 +31118 75373 +51627 61786 +89566 93643 +23542 37435 +54992 11280 +24990 37435 +33159 19657 +53499 17022 +84995 72286 +45818 50732 +41169 14636 +40120 26973 +64286 84321 +63432 30593 +99949 24130 +61077 17022 +36433 82246 +54816 59964 +85544 84321 +60397 52196 +76341 37081 +31479 79027 +16260 17420 +96337 10124 +65067 62284 +26483 44801 +96326 17022 +14058 54149 +13393 65898 +65901 53423 +38500 57276 +20118 79584 +44353 40727 +47498 49739 +93041 47833 +46970 46550 +33688 75373 +68223 90514 +87884 94553 +65159 37435 +58329 74006 +42199 37350 +76135 20844 +46639 93433 +65739 49055 +43290 40727 +31619 86698 +77506 86616 +65377 56317 +31884 84321 +52311 81238 +99796 93836 +51116 95658 +41167 73020 +16379 18876 +12306 97271 +31299 48015 +73188 70147 +11052 42268 +65938 89990 +26961 98705 +95494 58398 +59265 23555 +87502 32132 +70660 84797 +12091 89045 +41613 26719 +68419 20739 +26943 58398 +89349 89990 +16651 17022 +95467 28221 +89990 98021 +85616 86929 +16479 51259 +76664 83454 +78928 74941 +31423 45590 +93437 82778 +85851 52691 +76954 15659 +16646 74584 +48296 46550 +77084 70921 +27964 99119 +41032 78157 +32094 82246 +29499 49175 +79737 13077 +25423 68557 +12219 58628 +70282 29077 +87976 11280 +57871 43034 +81209 58398 +56626 45328 +29128 28793 +14975 38794 +58884 36392 +24278 46550 +77033 27547 +74285 73475 +10130 32903 +34728 11456 +40336 17022 +62399 45936 +95138 53688 +12955 16609 +74887 93836 +18948 93836 +28427 26898 +67749 80949 +94522 17022 +76210 82892 +78717 36081 +13088 80671 +80352 18670 +68720 41082 +62146 69651 +39371 84952 +41619 27315 +90093 58398 +32716 45626 +11280 27624 +22129 94534 +24812 10124 +43238 86431 +35791 97662 +13162 53170 +57534 15678 +66069 63618 +49841 11541 +23345 38097 +36649 79056 +37193 76443 +18519 64707 +34081 61786 +47018 75935 +30452 48882 +12559 58817 +32825 91051 +16051 19974 +80171 17022 +19374 54710 +57295 84738 +81314 38097 +33479 49965 +38611 79056 +63785 49754 +18774 70415 +98510 72330 +85801 73475 +10744 17022 +15097 11280 +52514 37435 +86860 96099 +27804 22005 +62601 79155 +86020 70452 +26991 15399 +98690 69989 +18491 79768 +85009 79056 +11329 20212 +10782 70405 +85026 40727 +26888 34001 +36315 42445 +49098 37435 +59474 38097 +86676 41947 +55178 84321 +53985 87526 +65575 47299 +57292 82817 +24657 37081 +82204 10439 +82639 73475 +81107 74139 +89946 97271 +93306 41394 +62863 46550 +48547 86956 +12374 55301 +81681 95539 +94195 84321 +15303 24017 +36395 93928 +28572 10804 +62931 45406 +33902 88845 +25697 83483 +86956 51476 +73957 55123 +83525 29803 +16581 19887 +96012 90129 +14067 40727 +66384 38351 +43782 75373 +53517 29489 +17126 71797 +10854 68046 +68594 89990 +89786 17022 +81737 11280 +71138 84321 +77457 62041 +99540 54740 +15369 87693 +73475 39716 +35348 99949 +67944 97271 +91345 20757 +48703 99901 +56450 84321 +75169 70680 +27015 45299 +34175 85030 +21184 64377 +95716 97271 +25738 70254 +79049 75062 +54904 68773 +12813 47161 +95857 74505 +17456 87526 +24008 30203 +92925 17022 +17008 98227 +53399 13325 +84080 49498 +23522 62070 +80392 37081 +67497 89518 +31797 46550 +67380 29610 +29237 47817 +32106 13477 +17711 61786 +19802 35480 +46456 37081 +17560 67389 +59598 64837 +30808 10592 +78213 86193 +34411 89045 +22714 61786 +88368 79584 +49172 37435 +28106 30525 +34595 65269 +67363 90595 +50389 33649 +57932 74115 +85665 15566 +68846 84257 +37420 75483 +70969 85030 +53989 74115 +30509 81520 +92232 63922 +12314 64612 +59372 76983 +31019 75373 +28072 58019 +51728 67527 +82597 36949 +66512 46706 +89805 89043 +13220 72753 +19121 31313 +27852 89644 +29411 97271 +10756 88672 +60773 82080 +81746 11688 +90653 23550 +59400 14905 +97489 44079 +20132 40678 +82210 43722 +90436 80985 +92889 18182 +40727 19573 +76922 17022 +27554 78420 +47592 87324 +78580 75728 +91390 63922 +82409 80324 +60005 53958 +46353 90334 +89672 26377 +52436 11280 +71495 41947 +59787 93836 +13621 79584 +16093 31156 +11603 51436 +31593 12955 +70829 89990 +61100 96353 +71072 61786 +33450 17022 +65493 48359 +51250 44884 +49691 61786 +41947 61786 +60973 93836 +44926 87954 +90989 35723 +98883 30386 +83974 67713 +86576 17323 +32534 77745 +57475 32708 +86499 43190 +26325 71687 +16737 58398 +88460 17022 +10798 61963 +59899 54790 +84722 56390 +38117 75766 +12595 97271 +23267 78757 +70504 97271 +44104 63922 +22950 85030 +66137 84321 +18407 99949 +37598 61786 +28201 24323 +19404 79868 +53725 33781 +56941 41947 +88231 83925 +30916 73475 +81019 46011 +91386 23123 +29455 79332 +32603 42378 +61578 46922 +67431 12955 +85884 15692 +40799 89045 +27326 97271 +79681 11280 +35614 38097 +99407 54190 +30288 10124 +59805 66109 +27031 12955 +51952 46550 +63420 17022 +96282 17307 +45123 17022 +95858 32553 +85339 98702 +19887 81650 +20177 66465 +92548 84663 +28915 38097 +48995 58398 +32153 97259 +14697 55843 +15115 31921 +97258 21175 +11833 75150 +20476 37081 +57780 87869 +20868 16813 +55154 72786 +51855 79056 +58551 94071 +32367 60493 +70926 16754 +95196 94004 +30949 32933 +93955 10128 +14553 61786 +67116 11579 +34377 85680 +69983 79584 +92220 38097 +69116 11280 +83291 10124 +63499 30127 +48167 97271 +70014 13990 +40226 78226 +71699 12411 +40455 75750 +74381 11343 +88846 74967 +17219 79739 +78747 30775 +98201 18354 +54571 68841 +85738 49837 +17375 10897 +44862 46550 +15932 11030 +79584 17022 +77641 58398 +54882 38097 +87246 75159 +33635 41878 +75249 60331 +46712 55151 +48228 91967 +17264 39458 +58907 86956 +62693 87904 +72122 43222 +70553 73934 +43027 90334 +69420 97905 +91527 10124 +34146 96995 +77998 88728 +80279 91008 +35125 77608 +33786 63922 +82027 38917 +10855 49903 +66407 38097 +50926 49360 +73591 97271 +97759 84321 +82742 49137 +16002 57753 +53455 38875 +66703 40727 +76244 92842 +87526 49664 +92147 87526 diff --git a/2024/src/bin/01.rs b/2024/src/bin/01.rs new file mode 100644 index 0000000..7f74d2e --- /dev/null +++ b/2024/src/bin/01.rs @@ -0,0 +1,31 @@ +use std::{fs::File, io::{BufRead, BufReader}}; + +use anyhow::{anyhow, Result}; +use aoc2024::{Context, Day}; +use itertools::Itertools; + +fn part1(ctx: &Context) -> Result { + let tuples = BufReader::new(File::open(&ctx.args.input)?).lines().map(|line| -> Result<_> { + let line = line?; + let nums = line.split_whitespace().map(|n| n.parse::()).filter_map(|n| n.ok()).collect_tuple::<(u32, u32)>().ok_or(anyhow!("Invalid input"))?; + + Ok(nums) + }); + + let mut first = Vec::new(); + let mut second = Vec::new(); + for res in tuples { + let (x, y) = res?; + first.push(x); + second.push(y); + } + first.sort(); + second.sort(); + let sum: u32 = first.iter().zip(second).map(|(x, y)| x.abs_diff(y)).sum(); + + Ok(sum.to_string()) +} + +fn main() { + Day::new().part1(part1).run(); +} \ No newline at end of file diff --git a/2024/src/lib.rs b/2024/src/lib.rs new file mode 100644 index 0000000..3518b3b --- /dev/null +++ b/2024/src/lib.rs @@ -0,0 +1,121 @@ +use anyhow::Result; +use clap::Parser; +use colored_diff::PrettyDifference; + +#[derive(Parser, Debug)] +#[command(version, about, long_about = None)] +pub struct Args { + /// Which part to run (empty for both) + #[arg(short, long)] + pub part: Option, + + /// Which input file to use + /// Will try to find an output file by replacing the extension with .out + #[arg(short, long)] + pub input: String, +} + +#[derive(Debug)] +pub struct Context { + pub args: Args, + pub day: u8, + pub output: String +} + +impl Context { + fn new() -> Self { + let args = Args::parse(); + let day = std::env::current_exe() + .unwrap() + .file_name() + .unwrap() + .to_str() + .unwrap() + .parse() + .unwrap(); + let mut output = args.input.clone(); + if let Some(pos) = output.rfind('.') { + output.replace_range(pos.., ".out"); + } + Self { args, day, output } + } + + fn read_output(&self) -> Option { + std::fs::read_to_string(&self.output).ok() + } +} + +type Part = fn(&Context) -> Result; + +#[derive(Debug, Default)] +pub struct Day { + part1: Option, + part2: Option, +} + +impl Day { + pub fn new() -> Self { + Self::default() + } + + pub fn part1(mut self, f: Part) -> Self { + self.part1 = Some(f); + self + } + + pub fn part2(mut self, f: Part) -> Self { + self.part2 = Some(f); + self + } + + fn has_part(&self, part: u8) -> bool { + match part { + 1 => self.part1.is_some(), + 2 => self.part2.is_some(), + _ => unreachable!() + } + } + + fn verify_part(&self, part: u8, ctx: &Context) -> Result<()> { + println!("Day {} Part {}", ctx.day, part); + let expected = ctx.read_output(); + let start = std::time::Instant::now(); + let result = match part { + 1 => self.part1.as_ref().unwrap()(ctx), + 2 => self.part2.as_ref().unwrap()(ctx), + _ => unreachable!() + }?; + let elapsed = start.elapsed(); + println!("Elapsed: {:?}", elapsed); + if let Some(expected) = expected { + println!("{}", PrettyDifference { + expected: &expected, + actual: &result + }); + if result != expected { + std::process::exit(1); + } + } else { + println!("{}", result); + std::fs::write(ctx.output.to_string() + ".run", &result)?; + println!("Output written to {}", ctx.output.to_string() + ".run"); + } + println!("OK"); + Ok(()) + } + + pub fn run(self) { + let ctx = Context::new(); + match ctx.args.part { + Some(i) => self.verify_part(i, &ctx).unwrap(), + _ => { + for i in 1..=2 { + if !self.has_part(i) { + continue; + } + self.verify_part(i, &ctx).unwrap(); + } + } + } + } +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..f45a584 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,423 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[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", + "code-timing-macros", + "colored-diff", + "const_format", + "itertools 0.13.0", + "regex", + "thiserror", +] + +[[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 = "code-timing-macros" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a376c20b26df1b21dd308080901b3341d4a2b36a01dcd503d719ea757645146" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "colorchoice" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + +[[package]] +name = "colored-diff" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "410208eb08c3f3ad44b95b51c4fc0d5993cbcc9dd39cfadb4214b9115a97dcb5" +dependencies = [ + "ansi_term", + "dissimilar", + "itertools 0.10.5", +] + +[[package]] +name = "const_format" +version = "0.2.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50c655d81ff1114fb0dcdea9225ea9f0cc712a6f8d189378e82bdf62a473a64b" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eff1a44b93f47b1bac19a27932f5c591e43d1ba357ee4f61526c8a25603f0eb1" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "dissimilar" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59f8e79d1fbf76bdfbde321e902714bf6c49df88a7dda6fc682fc2979226962d" + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[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 = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[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 = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[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 = "thiserror" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "unicode-ident" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[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" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..bcf83d2 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,3 @@ +[workspace] +members = ["2024"] +resolver = "2" \ No newline at end of file diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..ae8f641 --- /dev/null +++ b/shell.nix @@ -0,0 +1,42 @@ +{ pkgs ? import {} }: +let + # rust-rover things + rust-toolchain = + pkgs.symlinkJoin { + name = "rust-toolchain"; + paths = with pkgs; [rustc cargo rustPlatform.rustcSrc clippy rustfmt gcc rust-analyzer]; + }; +in +pkgs.mkShell rec { + buildInputs = with pkgs;[ + openssl + pkg-config + cmake + zlib + rust-toolchain + + # common glutin + libxkbcommon + libGL + + # winit wayland + wayland + + # winit x11 + xorg.libXcursor + xorg.libXrandr + xorg.libXi + xorg.libX11 + + # python + python3 + ]; + nativeBuildInputs = with pkgs; [ + pkg-config + fontconfig + ]; + LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}"; + OPENSSL_DIR="${pkgs.openssl.dev}"; + OPENSSL_LIB_DIR="${pkgs.openssl.out}/lib"; + RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; +}