From d9d61495647291ce65e26aa5a38efd8727de732b Mon Sep 17 00:00:00 2001 From: mstar Date: Mon, 2 Dec 2024 14:42:47 +0100 Subject: [PATCH] Day 1 and 2 done --- day1/input | 1001 ++++++++++++++++++++++++++++++++++++++++++++++ day1/main.go | 60 +++ day1/sampleTask1 | 6 + day2/input | 1000 +++++++++++++++++++++++++++++++++++++++++++++ day2/main.go | 124 ++++++ day2/sample | 6 + go.mod | 7 + go.sum | 8 + util/loadFile.go | 35 ++ 9 files changed, 2247 insertions(+) create mode 100644 day1/input create mode 100644 day1/main.go create mode 100644 day1/sampleTask1 create mode 100644 day2/input create mode 100644 day2/main.go create mode 100644 day2/sample create mode 100644 go.mod create mode 100644 go.sum create mode 100644 util/loadFile.go diff --git a/day1/input b/day1/input new file mode 100644 index 0000000..9971abe --- /dev/null +++ b/day1/input @@ -0,0 +1,1001 @@ +35446 18696 +46314 66062 +33933 83974 +83974 34443 +98207 12657 +38488 57125 +95930 81859 +52767 12657 +16477 53659 +14481 84757 +29083 51122 +36158 15438 +61387 10295 +76932 66328 +36700 83181 +90500 70317 +55528 55820 +31179 94554 +22822 16886 +23069 99080 +69000 50666 +91611 49688 +10965 12657 +62470 27096 +38922 83974 +88317 67082 +49184 78816 +46731 90213 +56390 89965 +67724 21120 +60777 88500 +38607 91051 +89620 42599 +19492 59958 +12399 89965 +14491 21092 +89224 65224 +92053 89616 +61752 33001 +14662 46961 +62308 99609 +63106 37570 +98323 89620 +10130 47868 +44468 92294 +55055 99080 +21162 23460 +62629 83614 +64760 76835 +59948 58492 +93112 81859 +19027 67250 +68050 27547 +39607 27547 +72923 77124 +59390 45817 +33001 47868 +70458 64427 +36441 47868 +44963 70577 +56327 83974 +35920 89031 +56574 16410 +19886 20797 +10538 56032 +43629 89965 +40166 54408 +71819 87037 +71239 58805 +84091 36969 +27282 83974 +61675 83974 +13092 65566 +22564 69172 +73337 83623 +65255 88498 +14204 49627 +90941 12657 +12650 65455 +39913 16886 +91204 42662 +12353 24980 +86940 43602 +45417 86117 +93805 13685 +86595 32060 +95504 49974 +49450 18696 +54656 82794 +24239 65070 +39200 94275 +45741 65455 +86169 41093 +30646 56972 +28947 45593 +27981 18232 +74967 83592 +28791 27193 +58805 69918 +41082 52767 +49770 52767 +40558 92562 +38248 72945 +51400 16886 +20599 11817 +77640 81133 +54049 56972 +82155 36807 +88848 49688 +74986 21092 +84534 83372 +52277 53938 +27375 46406 +82985 44993 +44699 83974 +56937 87037 +77717 49519 +97383 12353 +94620 17706 +93133 79684 +63717 33001 +13006 56032 +20078 55429 +68979 18696 +97191 84071 +47911 62971 +48256 56784 +34443 47868 +44941 56972 +43750 83153 +16717 42999 +36163 79265 +29877 82188 +54069 59608 +21897 70982 +46002 35871 +47632 28298 +92150 34443 +47440 90606 +21000 89334 +22797 91051 +67853 81395 +30016 59612 +65558 65566 +46885 12353 +49714 12353 +40300 27547 +97130 33789 +89917 70893 +99566 49688 +53392 56972 +92478 44580 +69059 12657 +88594 66111 +25017 51845 +66050 49129 +18086 33001 +44548 56032 +91368 26310 +90745 82691 +50489 65566 +29928 45682 +81859 89620 +74633 95869 +98553 47868 +80866 49688 +24016 20910 +36650 33001 +19561 74850 +63484 49688 +58451 18696 +29016 32060 +54718 25325 +89003 33001 +68471 11145 +88206 89620 +13290 66328 +86949 22014 +77758 88623 +75063 96681 +99425 31778 +71300 62538 +88500 11195 +78917 56972 +43065 88068 +33189 89088 +46705 83036 +56972 50663 +24844 91051 +57908 63316 +15446 88452 +76421 36179 +98232 25703 +37640 49688 +35383 44539 +11291 12353 +62140 83592 +55579 88733 +83570 87934 +76450 35834 +84820 47091 +24416 78402 +45763 65455 +82938 66922 +65397 65566 +45162 18361 +71395 72305 +72027 97029 +85465 28881 +32751 65455 +65455 80742 +79640 10727 +88492 84005 +66028 32752 +23677 43498 +22716 26101 +62036 87090 +18882 82877 +24085 91061 +97952 56032 +16125 12353 +69534 44480 +42997 33448 +45250 68695 +84290 92562 +22335 32582 +47550 99080 +36928 73869 +40790 11220 +41540 71545 +16448 67875 +44580 45593 +35045 70157 +69798 63807 +50519 97965 +69580 16886 +87702 24341 +57895 58808 +20766 27547 +74455 59612 +33358 83592 +80944 78627 +71806 29266 +88258 82877 +21771 64556 +88011 25173 +95793 49627 +95847 45593 +56747 12657 +32448 12657 +93453 50250 +72594 74557 +52172 18099 +93959 70300 +74332 38126 +79878 67746 +49680 54928 +18265 33001 +95331 59612 +18366 33001 +25504 88500 +62474 60901 +31197 29540 +66986 49688 +63340 88500 +69519 27915 +21052 52553 +72184 27193 +43404 49627 +95052 59327 +27977 83614 +13673 18696 +13363 27547 +82059 47868 +52928 82877 +55266 25800 +55292 89620 +66838 81751 +85014 62704 +18772 89391 +99322 39583 +68363 58608 +45148 58708 +63006 27193 +92687 12754 +55913 75671 +45593 65455 +79018 51305 +87110 56230 +66328 14246 +54561 53594 +56406 14740 +95001 49947 +12373 81859 +65064 16886 +17403 75896 +58690 53427 +50959 27547 +40939 52963 +50275 47946 +73990 32060 +39728 49688 +64531 74946 +44868 56972 +72719 27906 +35784 16310 +13911 26147 +45218 21092 +27025 54743 +64719 65566 +22135 12657 +13725 71262 +16787 49149 +26004 27547 +83956 25800 +20869 65750 +92705 49627 +41237 33001 +47868 54678 +46965 44772 +76833 67617 +10593 96338 +91447 12858 +41369 18696 +88036 97875 +56077 40100 +83258 73796 +17955 99080 +47587 12353 +71731 21884 +43926 76598 +26878 21142 +85135 21092 +13199 91051 +55583 72621 +72584 63423 +10908 82877 +59612 45593 +72725 95288 +22111 82877 +15422 16886 +51152 97377 +14804 61202 +62625 53427 +89653 38262 +13230 39503 +83705 39416 +88216 34340 +30601 23296 +86040 70921 +76367 32060 +17566 62842 +49688 26555 +51987 27192 +99083 16886 +50529 28284 +18618 92562 +49357 27193 +83692 27547 +34017 12353 +34588 65455 +79808 56032 +76557 83614 +52422 73787 +99664 83974 +23712 89620 +10628 79497 +35405 89633 +55143 97586 +97421 13687 +17759 32060 +94690 46885 +40501 39940 +41037 85460 +70591 40719 +64400 83974 +25588 12353 +92616 83974 +65267 12288 +21298 82152 +21216 24498 +83830 95148 +69200 34443 +92744 83974 +84255 72646 +60019 33001 +72406 89620 +80749 83614 +81952 73514 +80454 27193 +32161 15624 +96805 12657 +87229 45593 +52706 21688 +54224 33221 +59272 81859 +39664 89965 +52726 88500 +17451 53746 +53896 58280 +72032 56972 +41654 83606 +45801 76761 +59531 56972 +69619 65455 +47931 88500 +37408 15916 +46419 27677 +24027 99080 +87213 89400 +59190 71907 +91014 77947 +20262 52969 +99705 17001 +77899 98899 +66940 12657 +96845 16886 +85833 89620 +24005 72223 +70935 48677 +80570 92562 +14398 81859 +34541 83183 +28018 92562 +87037 90231 +71966 34443 +46070 83974 +28730 56032 +37205 65566 +78756 83974 +92078 88687 +84234 22235 +65644 83974 +69979 57474 +26206 40074 +10787 70635 +25443 81859 +16577 86943 +83988 11918 +12284 12657 +57347 16886 +25269 45386 +26028 52805 +28804 77340 +50690 72129 +79036 63115 +70738 71491 +66916 96652 +81977 46885 +43130 58805 +97899 98026 +50454 97303 +77142 33793 +20238 99451 +25279 49627 +37235 83614 +49627 84495 +40512 15742 +84237 18675 +57852 65767 +60277 53427 +60816 99080 +48621 62202 +48990 65455 +90883 47035 +32060 33001 +47930 56032 +53524 55589 +76420 16886 +12331 72983 +93348 48516 +21092 40456 +80416 62693 +18172 66930 +83267 47868 +56035 31836 +19129 12657 +31465 83592 +64173 33001 +74397 70918 +20717 12819 +51944 72328 +71053 27547 +80370 56032 +68857 90951 +48914 33001 +41820 53931 +31445 99080 +12669 38918 +79174 56972 +45196 22048 +43488 27193 +49986 39514 +65806 85882 +48018 89620 +86144 92562 +95852 58805 +47095 89620 +96313 45593 +39688 86998 +89088 56972 +10994 27193 +44290 45593 +32871 49668 +74126 69396 +59913 35109 +37148 83974 +56032 24108 +92348 23837 +76049 45593 +28805 74542 +35070 46272 +40283 47868 +32870 21092 +87890 11410 +85129 84836 +89021 23016 +54444 52767 +60250 15651 +82877 99080 +13101 66125 +95310 44178 +99602 87037 +39771 61194 +92562 67527 +26053 81299 +99211 52767 +31519 14876 +66988 89620 +55719 34142 +47519 37927 +81355 67645 +64580 83371 +53953 40028 +28575 23345 +88211 96106 +25538 33194 +35298 66440 +11466 12353 +33575 18696 +86250 59305 +84467 53562 +59023 91051 +81764 58973 +80503 18696 +73651 65455 +74173 65566 +59081 38453 +54695 27547 +25202 43565 +90138 53680 +87761 98899 +76616 26486 +98411 12657 +87945 89620 +69634 64725 +94813 92562 +64622 21092 +46511 18696 +49212 70971 +34375 23916 +64884 81859 +94136 95813 +89737 59612 +45383 16739 +60780 34100 +60956 56032 +27402 25216 +61698 78097 +77163 74327 +30740 83974 +78975 99080 +34208 88571 +74233 14179 +95918 47868 +74949 65566 +41203 47868 +27671 56032 +38515 20386 +82734 92813 +70727 25800 +10326 33001 +83563 45593 +46938 58588 +43092 65566 +96771 57693 +32365 21390 +65514 25800 +21151 91810 +53822 66328 +89965 49039 +97207 20005 +18794 23172 +85061 82877 +29500 93001 +86025 29962 +18550 74091 +92402 69893 +58049 16886 +47165 82877 +40002 81859 +82066 71414 +99593 12657 +95278 82877 +23474 33508 +26508 32060 +13412 78711 +58286 35717 +79549 25448 +59275 87684 +59102 83592 +59475 65455 +71391 49481 +64011 27193 +34907 27193 +96020 65566 +32676 48353 +82228 64987 +85683 33001 +84073 49627 +89790 91054 +79448 42717 +57726 66328 +30683 65566 +27124 74353 +13404 65566 +47973 32110 +75389 32060 +39880 90141 +47176 25763 +77298 75035 +36334 32060 +55391 40175 +75215 50282 +89669 27719 +36393 33001 +79118 21092 +81448 47868 +51834 49990 +40739 49688 +52754 56972 +35389 36568 +31791 30926 +44345 27193 +11231 58125 +21968 32060 +78789 12353 +81898 62528 +22004 84635 +50202 69626 +83592 51107 +58853 79346 +42190 68523 +45830 99080 +81738 12353 +99265 99469 +90691 38910 +38908 20889 +20275 89965 +24933 24939 +71243 83614 +67641 13684 +63940 34940 +16484 46405 +95114 80965 +52206 65455 +45310 68999 +76892 94531 +71763 25077 +28803 25055 +19132 65455 +62482 16017 +20185 65455 +53459 47868 +86711 18696 +25418 70965 +41208 97960 +18696 38086 +25923 21953 +90443 92562 +84272 27547 +58778 45593 +83614 10136 +46699 32890 +76064 27547 +99080 28452 +18497 12353 +60862 77196 +19752 27547 +22338 53427 +66112 32195 +41917 82202 +50594 45593 +15550 96715 +61435 88975 +96294 32060 +47560 77044 +60387 49627 +76943 45593 +78435 87312 +57089 89620 +97691 18696 +30869 76316 +51101 17127 +89100 49688 +28552 99080 +50599 21092 +62850 89620 +97312 27547 +81531 45593 +69183 54914 +88793 56972 +48548 45593 +66705 56032 +71169 16358 +55885 12353 +55064 66328 +59988 38915 +89486 45971 +66564 62229 +21432 73083 +69247 49688 +15787 12657 +91085 82877 +14618 12353 +99031 46480 +80969 91051 +68503 18696 +89919 12657 +97125 81859 +36492 34656 +50873 18696 +50741 27547 +27193 99250 +13260 89620 +70660 50852 +23872 40621 +23133 34336 +18937 49627 +84631 18350 +31466 97019 +82842 70754 +96642 16614 +99278 21092 +37578 44363 +87003 59612 +43407 43149 +73286 92643 +45369 18696 +60219 47988 +92605 12811 +80646 91257 +29493 25800 +64968 16886 +67454 56032 +39669 52921 +45812 92562 +98524 34245 +68102 13668 +33914 59590 +90204 20381 +78331 21373 +41990 17121 +98264 13737 +12657 97505 +14876 12560 +86663 13560 +81960 46045 +94521 12578 +84699 89846 +65933 89620 +69417 46940 +77051 30362 +75075 44987 +33494 56972 +49618 81859 +71385 41628 +72195 47868 +62025 65455 +23253 49627 +70062 81859 +14577 16886 +72180 61232 +92457 12657 +91879 53427 +49809 97285 +73214 49688 +63136 65455 +25107 99080 +77516 18306 +84079 45956 +68470 12935 +80077 35901 +33487 93929 +98439 81859 +25106 49627 +29578 21746 +41763 49627 +38888 82877 +21105 59612 +27547 85476 +34649 96912 +98652 37966 +26548 51315 +91140 70379 +88522 66328 +18801 81859 +88360 27197 +54575 33001 +54004 83017 +50564 99080 +19887 42385 +65566 93192 +13908 81859 +38021 51863 +53431 65566 +63143 49688 +77152 16886 +95334 94999 +99112 84555 +22226 47868 +81497 25800 +56613 89560 +32899 66913 +73926 32060 +14710 59039 +81998 56498 +51537 23626 +92298 72999 +61627 48753 +25800 33001 +89153 35814 +15490 59612 +98839 49749 +88591 27547 +47330 83974 +94242 38771 +30493 25606 +47111 97620 +76006 83974 +88435 49627 +12581 14185 +52999 82877 +64534 46741 +70617 18696 +78842 89208 +72607 51926 +44479 91090 +32783 26114 +27725 65566 +71384 17667 +75007 81596 +25465 98911 +97702 81141 +87869 32060 +85114 81859 +67686 97990 +22260 12353 +67159 32060 +97547 16886 +26163 79445 +90733 83974 +62958 47018 +87531 53073 +28421 82286 +31349 92110 +62113 17868 +59754 42706 +82004 12353 +69805 89458 +73669 77228 +36269 97413 +35228 27547 +38938 12657 +88675 89620 +90579 71041 +89858 83974 +19686 18696 +16625 49627 +91432 81859 +17607 83974 +89530 45593 +40107 56032 +28095 41567 +93573 70856 +85006 18696 +19091 45593 +82765 12657 +20545 24253 +24106 49627 +60438 88622 +27926 16886 +97985 89965 +79204 89810 +91051 83614 +75382 82877 +50290 96422 +66045 81859 +61679 35777 +46984 56988 +18043 21092 +53300 90453 +57214 78410 +11949 81859 +45225 22918 +82542 65566 +11498 27547 +44155 56972 +97659 13416 +64945 53035 +10456 52940 +66710 16886 +52752 68386 +21492 63909 +10804 70233 +53427 70763 +81459 89620 +24486 29799 +94315 88192 +99345 81859 +26426 16886 +59747 65455 +78335 28188 +76856 55257 +38024 89620 +76867 76062 +25261 27547 +21948 44580 +25796 49407 +26541 34513 +85517 29546 +51634 23929 +16886 98484 +94563 31195 +94244 82759 +19517 83614 +15629 47203 +13661 64125 +54946 63802 +69496 18696 +10488 32505 +92729 23426 +28136 32060 +55489 83964 +34355 47868 +75542 76179 +70632 99080 +29904 71317 +73989 53368 +86241 48586 +82353 46831 +78028 53147 +92984 83641 +55747 21015 +17389 18696 +94992 29411 +69555 88500 +66820 26798 +96784 92681 +19019 99080 +67383 42448 +64708 12353 +20616 92061 +22213 89965 +34850 12996 +99572 36736 +76670 92372 +11930 91013 +18321 99080 +42025 57447 +99887 75845 +95958 48242 +44579 18696 +79387 34443 +82753 27308 +93967 52098 +90819 66336 +38322 35403 +10019 12353 +78459 37576 +69905 16060 +14796 98743 +14487 17417 +79979 66300 +59836 12353 +37308 56032 +63835 88500 +30048 79432 +71914 99080 +76352 56972 +74621 56972 +33804 98899 +23449 33001 +99868 27547 +57457 83513 +44296 36718 +43642 99921 +49243 90701 +28205 27193 +98899 19172 + diff --git a/day1/main.go b/day1/main.go new file mode 100644 index 0000000..824b07d --- /dev/null +++ b/day1/main.go @@ -0,0 +1,60 @@ +package main + +import ( + "fmt" + "slices" + "strconv" + "strings" + + "git.mstar.dev/mstar/aoc24/util" + "git.mstar.dev/mstar/goutils/sliceutils" +) + +func LineExtract(line string) (int, int) { + tmp := sliceutils.Filter(strings.Split(line, " "), func(s string) bool { + return len(s) > 0 + }) + if len(tmp) != 2 { + return 1, 1 + } + left, err := strconv.Atoi(tmp[0]) + if err != nil { + panic(err) + } + right, err := strconv.Atoi(tmp[1]) + if err != nil { + panic(err) + } + return left, right +} + +func main() { + data := util.LoadFileFromArgs() + lines := sliceutils.Filter( + strings.Split(string(data), "\n"), + func(t string) bool { return len(t) > 0 }, + ) + + numbersLeft := []int{} + numberRight := []int{} + for _, line := range lines { + l, r := LineExtract(line) + numbersLeft = append(numbersLeft, l) + numberRight = append(numberRight, r) + } + slices.Sort(numberRight) + slices.Sort(numbersLeft) + + diffs := make([]int, len(lines)) + for i := range len(lines) { + diffs = append(diffs, util.AbsI(numbersLeft[i]-numberRight[i])) + } + total := sliceutils.Compact(diffs, func(acc, next int) int { return acc + next }) + fmt.Printf("Task 1: %d\n", total) + + acc := 0 + for _, v := range numbersLeft { + acc += len(sliceutils.Filter(numberRight, func(t int) bool { return t == v })) * v + } + fmt.Printf("Task 2: %d\n", acc) +} diff --git a/day1/sampleTask1 b/day1/sampleTask1 new file mode 100644 index 0000000..b8af9ad --- /dev/null +++ b/day1/sampleTask1 @@ -0,0 +1,6 @@ +3 4 +4 3 +2 5 +1 3 +3 9 +3 3 diff --git a/day2/input b/day2/input new file mode 100644 index 0000000..a2dc7aa --- /dev/null +++ b/day2/input @@ -0,0 +1,1000 @@ +45 47 48 51 54 56 54 +76 79 81 84 84 +30 32 35 36 38 40 44 +72 74 77 78 85 +54 55 58 57 60 +61 64 67 66 68 67 +5 7 6 9 12 14 16 16 +82 83 84 82 85 88 91 95 +38 40 43 46 49 47 53 +23 26 28 31 34 35 35 36 +74 75 78 80 81 81 79 +11 13 16 17 18 18 20 20 +20 21 22 23 23 27 +63 64 64 65 68 71 73 79 +44 47 49 53 55 56 58 59 +81 82 84 87 88 92 89 +32 35 38 40 44 44 +53 55 59 60 62 64 65 69 +53 55 56 58 62 67 +57 59 62 68 71 73 74 75 +22 24 25 30 33 35 38 36 +15 17 20 25 28 30 32 32 +83 85 88 94 98 +74 77 78 80 87 92 +57 55 58 61 63 64 65 67 +74 71 73 74 75 73 +32 31 34 35 35 +35 32 34 36 38 40 42 46 +35 32 33 34 36 41 +69 67 66 67 70 71 74 75 +93 91 89 91 94 93 +95 93 92 94 96 96 +23 22 21 22 23 24 28 +27 24 25 26 28 26 29 36 +86 84 86 86 88 +2 1 2 3 3 6 9 7 +35 33 35 35 36 36 +15 13 14 14 16 18 19 23 +73 70 70 71 78 +21 20 23 25 28 32 33 35 +27 25 27 28 32 34 31 +40 39 40 44 44 +67 64 67 71 75 +31 28 29 32 33 37 44 +9 8 11 14 17 19 25 28 +42 41 46 49 51 50 +22 21 26 28 31 33 36 36 +20 19 26 28 32 +32 29 30 37 40 43 48 +20 20 23 25 28 31 32 35 +69 69 72 75 76 75 +51 51 53 54 54 +46 46 47 48 49 53 +72 72 75 76 77 78 80 85 +53 53 54 52 54 +79 79 78 79 78 +72 72 75 73 75 75 +47 47 49 52 54 51 55 +19 19 20 18 21 26 +84 84 85 85 88 91 93 94 +29 29 29 31 33 36 33 +15 15 17 18 21 21 21 +61 61 61 64 67 71 +62 62 63 64 64 70 +64 64 67 71 72 75 77 79 +60 60 63 67 70 68 +76 76 79 81 85 87 88 88 +20 20 23 26 28 31 35 39 +29 29 33 35 42 +25 25 30 32 35 +50 50 52 59 60 62 60 +60 60 61 63 68 69 69 +81 81 83 86 87 92 96 +68 68 73 76 81 +21 25 26 28 31 32 35 38 +38 42 43 44 45 43 +35 39 42 44 46 46 +19 23 24 26 28 29 33 +54 58 60 63 65 67 73 +33 37 38 40 42 39 42 44 +65 69 70 67 68 65 +9 13 10 13 13 +78 82 79 81 83 87 +34 38 40 38 40 41 48 +15 19 19 21 24 +36 40 42 42 39 +4 8 9 9 9 +52 56 57 60 61 61 65 +50 54 56 57 57 60 66 +26 30 32 36 37 +9 13 16 20 22 23 20 +55 59 61 65 65 +45 49 50 53 57 60 63 67 +74 78 82 84 90 +41 45 50 53 56 +72 76 82 83 85 82 +1 5 11 12 12 +72 76 79 81 82 89 93 +54 58 64 65 70 +66 72 74 77 79 81 84 87 +47 53 55 57 60 62 59 +71 78 79 81 82 84 84 +52 57 59 62 64 65 69 +59 64 67 69 71 74 76 83 +78 83 85 82 83 85 86 89 +27 32 34 37 40 37 35 +37 42 40 41 44 44 +44 51 54 51 53 57 +18 24 27 30 32 31 36 +57 63 66 68 68 69 71 72 +65 70 70 71 73 72 +32 37 37 39 42 42 +43 50 52 52 55 58 61 65 +20 26 28 28 29 30 33 38 +50 55 59 62 64 65 66 +44 51 52 56 57 58 61 59 +12 17 18 21 25 26 28 28 +2 9 11 15 19 +61 68 72 73 78 +17 22 28 30 33 +58 64 67 72 74 71 +72 78 79 85 88 90 90 +69 74 76 83 85 89 +24 31 34 35 36 42 49 +22 19 16 14 12 10 9 12 +74 72 70 67 66 66 +42 40 39 36 32 +95 93 92 91 85 +70 68 67 66 65 67 66 63 +82 79 77 74 77 74 77 +74 72 70 71 68 68 +97 95 94 96 93 91 87 +13 11 9 10 8 2 +13 10 8 8 6 4 +80 78 75 75 73 70 72 +64 63 63 60 60 +54 51 50 50 46 +35 32 29 28 28 27 21 +87 85 81 80 78 +27 25 22 18 17 14 17 +94 92 88 85 82 79 78 78 +19 16 15 11 10 7 3 +46 44 42 41 37 34 29 +54 52 49 44 43 41 40 +29 27 26 20 21 +97 95 92 85 85 +55 54 52 47 46 42 +32 31 28 26 23 21 16 9 +43 44 42 40 39 38 +14 15 14 12 11 10 13 +48 50 47 46 46 +90 93 90 87 85 82 78 +78 80 77 74 72 69 68 62 +32 35 37 35 32 29 28 26 +15 16 17 15 14 13 16 +62 65 63 65 65 +75 77 75 78 74 +4 7 5 7 6 1 +98 99 96 93 93 90 +52 55 55 54 57 +76 79 79 78 75 75 +75 77 74 74 73 70 66 +21 23 22 21 21 19 17 12 +79 81 80 76 75 +69 71 69 65 63 61 59 60 +71 73 71 70 69 65 64 64 +59 61 59 56 54 50 46 +86 89 85 84 83 77 +53 55 54 48 47 44 42 39 +13 16 15 14 12 5 6 +63 64 63 60 54 52 52 +55 56 54 47 43 +33 36 33 32 27 22 +30 30 28 27 25 24 21 19 +14 14 12 11 10 12 +34 34 32 31 30 27 24 24 +18 18 17 16 12 +21 21 19 16 10 +26 26 27 24 21 20 +68 68 67 66 64 66 63 64 +77 77 80 78 76 73 73 +71 71 73 71 69 66 65 61 +25 25 24 23 21 19 20 15 +46 46 46 45 44 41 38 37 +73 73 72 70 68 68 67 68 +54 54 54 53 51 49 49 +47 47 47 46 44 43 39 +72 72 70 69 67 67 62 +93 93 90 89 85 82 81 78 +54 54 53 49 47 48 +24 24 20 19 19 +93 93 89 87 83 +30 30 28 24 22 20 14 +97 97 90 88 87 +76 76 71 68 67 66 65 66 +81 81 75 72 72 +50 50 45 42 41 37 +75 75 69 67 61 +49 45 42 41 38 36 +56 52 50 49 46 45 47 +31 27 24 22 19 18 18 +42 38 37 34 33 30 26 +77 73 71 70 67 65 63 58 +36 32 29 26 24 23 25 22 +46 42 39 41 43 +85 81 82 80 78 78 +49 45 43 45 41 +63 59 62 59 54 +91 87 85 85 82 +68 64 62 59 59 61 +9 5 5 4 4 +74 70 68 68 67 63 +25 21 19 18 16 13 13 7 +69 65 64 60 57 54 +68 64 60 59 58 57 60 +94 90 89 87 85 84 80 80 +28 24 20 18 16 12 +26 22 20 16 11 +95 91 89 83 80 +36 32 29 28 23 24 +82 78 75 70 70 +58 54 49 47 44 40 +52 48 47 45 39 32 +98 93 92 90 89 86 84 +32 25 23 20 18 15 17 +26 19 18 15 14 13 10 10 +33 28 26 23 20 18 15 11 +84 78 75 74 73 70 69 64 +86 79 78 76 74 77 74 +73 67 65 62 63 64 +90 84 81 83 83 +94 87 86 84 87 83 +40 33 32 30 33 32 29 24 +25 19 18 18 15 14 +86 80 79 79 78 77 76 77 +10 4 3 3 3 +55 48 48 47 43 +98 92 91 90 87 87 81 +21 16 12 11 9 7 4 2 +27 22 19 15 14 11 12 +22 17 13 12 10 10 +97 90 89 86 82 81 77 +99 94 91 87 82 +72 67 64 63 62 55 53 +63 56 54 53 52 51 44 46 +46 39 36 33 31 26 26 +48 42 37 35 31 +27 20 14 13 11 8 1 +15 17 18 21 23 25 26 24 +65 68 71 74 77 80 81 81 +23 26 28 29 31 32 36 +84 86 87 90 92 93 98 +89 90 91 94 96 95 96 +24 25 26 28 25 26 25 +34 37 34 37 37 +24 26 29 28 32 +72 74 72 73 75 80 +91 93 93 94 97 +21 23 25 25 22 +29 32 35 37 37 37 +52 54 54 56 57 61 +21 23 23 24 30 +16 18 19 23 26 28 29 32 +81 84 88 89 91 94 95 92 +55 57 61 63 63 +77 79 80 82 84 87 91 95 +18 20 21 24 28 31 34 40 +22 23 26 32 35 +29 32 33 35 36 41 38 +25 28 29 31 33 34 39 39 +1 4 9 12 16 +31 33 34 41 44 51 +90 87 89 90 92 93 95 96 +32 30 31 33 31 +85 82 83 85 88 90 90 +76 73 76 78 80 81 82 86 +26 25 27 30 33 35 38 43 +66 64 67 69 71 70 73 +56 53 52 54 57 60 59 +78 75 73 74 74 +7 5 7 5 9 +57 55 53 55 58 61 64 71 +78 76 77 77 79 82 +54 52 52 54 51 +53 50 53 53 53 +88 86 89 91 92 94 94 98 +85 83 83 85 86 92 +6 3 7 9 12 14 +17 16 18 22 24 26 23 +20 17 20 23 24 28 30 30 +58 56 58 59 63 67 +8 5 9 10 17 +77 74 75 77 78 80 87 89 +82 81 82 84 85 87 94 92 +81 78 79 84 84 +60 58 60 61 64 71 75 +66 63 65 71 76 +62 62 65 68 70 72 +22 22 24 26 24 +16 16 18 21 21 +30 30 33 36 38 42 +46 46 47 50 51 52 59 +3 3 4 2 4 6 9 11 +15 15 12 14 16 17 19 17 +32 32 35 34 34 +92 92 95 92 93 94 98 +73 73 70 73 76 83 +18 18 18 21 22 +39 39 42 42 43 41 +88 88 89 92 92 94 96 96 +27 27 27 30 32 36 +63 63 65 66 66 72 +31 31 35 38 39 40 41 +10 10 12 16 17 19 17 +38 38 42 43 45 45 +57 57 61 62 63 65 68 72 +11 11 14 18 21 23 24 31 +63 63 69 71 74 75 +8 8 13 16 15 +22 22 23 26 33 35 35 +7 7 10 13 16 21 25 +20 20 23 24 29 34 +79 83 86 88 91 93 +38 42 44 45 48 51 53 51 +36 40 42 43 45 45 +23 27 29 31 35 +69 73 74 76 81 +14 18 21 22 25 24 27 30 +36 40 37 38 40 42 40 +9 13 11 14 16 16 +73 77 75 78 82 +29 33 31 33 39 +23 27 30 30 32 34 +57 61 64 65 68 68 69 67 +16 20 20 23 24 26 26 +23 27 30 30 31 32 36 +72 76 76 79 86 +53 57 59 60 64 65 67 68 +63 67 71 74 71 +86 90 91 95 96 99 99 +62 66 69 73 77 +61 65 69 70 75 +23 27 30 36 39 40 41 42 +30 34 37 38 39 42 47 46 +50 54 56 61 61 +21 25 27 32 36 +22 26 27 33 36 38 45 +29 34 37 39 40 42 +31 36 38 39 40 43 46 43 +34 39 42 43 46 48 51 51 +29 35 36 37 40 43 46 50 +23 30 33 34 37 40 43 50 +90 95 96 93 95 +58 64 66 69 67 66 +29 34 37 40 37 40 43 43 +24 29 32 35 38 39 37 41 +11 18 17 19 20 27 +49 56 59 59 62 +87 93 96 97 97 96 +5 11 11 12 15 16 16 +45 50 50 51 53 57 +65 71 74 74 81 +35 42 46 47 48 51 54 +76 81 82 83 87 89 87 +2 7 8 11 15 17 17 +30 36 39 43 46 50 +48 53 54 56 60 63 64 70 +75 81 87 88 90 91 +27 32 34 36 41 39 +81 88 95 98 98 +32 38 45 46 49 52 53 57 +45 50 52 58 59 66 +75 72 69 67 68 +16 13 10 9 8 6 6 +96 95 94 91 88 87 83 +44 41 39 37 35 32 27 +34 32 33 30 27 +64 61 60 58 56 54 55 58 +56 55 54 57 54 51 51 +41 39 42 41 39 38 34 +26 25 24 26 25 19 +21 19 17 17 16 +89 86 85 84 83 83 80 83 +15 12 12 9 9 +52 49 47 47 43 +50 49 49 46 43 41 38 31 +97 95 94 92 91 87 86 +39 37 36 33 32 29 25 26 +77 76 73 72 70 67 63 63 +22 20 16 14 11 7 +34 32 31 28 24 23 16 +31 29 26 24 17 15 13 11 +81 79 77 70 67 65 66 +67 64 58 55 55 +22 19 17 14 12 11 6 2 +36 35 34 33 31 30 23 17 +14 15 12 10 7 +15 17 14 11 13 +3 6 5 4 3 3 +68 71 69 67 64 62 58 +34 37 35 32 25 +29 32 29 28 25 27 24 +20 21 24 22 20 19 21 +86 87 84 81 83 82 82 +16 19 17 14 13 11 13 9 +27 28 31 29 28 23 +61 62 62 59 56 55 54 +28 31 29 29 26 28 +78 79 79 76 73 70 70 +18 20 19 17 17 13 +40 41 40 40 38 36 35 28 +87 88 87 83 81 78 +41 44 41 40 39 35 33 35 +88 90 89 85 85 +25 27 23 22 19 18 14 +97 98 95 94 90 87 82 +90 93 87 85 84 82 79 +87 90 89 86 84 78 81 +67 70 65 64 61 61 +94 97 94 92 89 83 79 +57 59 57 52 46 +66 66 63 62 59 +39 39 36 35 32 29 32 +64 64 62 59 57 54 54 +27 27 26 24 21 20 16 +41 41 40 38 36 35 28 +78 78 76 73 70 68 70 69 +54 54 52 51 54 53 50 52 +55 55 54 51 54 53 53 +30 30 29 32 31 27 +97 97 96 99 98 93 +86 86 86 83 80 78 75 72 +93 93 91 89 89 90 +97 97 97 95 95 +62 62 60 57 57 56 52 +75 75 73 73 71 69 62 +50 50 46 44 41 40 +80 80 79 75 73 71 68 69 +38 38 36 33 29 29 +98 98 95 91 87 +78 78 75 73 69 68 63 +84 84 82 79 76 74 67 66 +19 19 16 10 8 11 +32 32 25 22 20 19 16 16 +23 23 22 21 19 13 10 6 +80 80 73 72 71 68 62 +81 77 75 73 72 71 70 69 +65 61 60 58 61 +17 13 10 8 8 +90 86 83 81 77 +69 65 63 62 61 55 +46 42 39 36 38 35 34 +58 54 53 55 56 +80 76 73 76 74 74 +63 59 57 54 53 56 54 50 +45 41 43 42 35 +23 19 19 16 14 +55 51 50 49 49 48 47 48 +96 92 90 87 84 81 81 81 +86 82 80 77 77 74 70 +95 91 90 90 84 +44 40 38 37 36 32 29 +95 91 87 85 82 85 +96 92 91 87 85 85 +66 62 59 55 51 +40 36 32 31 29 27 22 +77 73 71 68 62 61 58 55 +87 83 81 79 73 72 71 74 +52 48 47 41 38 36 36 +88 84 81 76 74 71 67 +89 85 82 79 73 70 63 +87 80 77 75 72 71 +18 12 11 9 7 6 9 +98 92 89 88 88 +78 73 70 69 66 63 60 56 +41 35 32 30 29 23 +39 33 31 28 30 29 +69 64 65 62 64 +59 54 51 52 51 49 47 47 +69 62 64 61 57 +54 48 45 42 41 43 41 34 +60 53 50 48 45 44 44 41 +52 46 46 45 48 +37 30 27 27 24 24 +91 84 84 82 80 76 +94 87 86 83 83 76 +38 32 28 25 23 20 19 17 +17 11 7 6 4 5 +65 58 57 55 52 48 47 47 +60 55 51 48 44 +63 58 55 52 50 46 43 36 +37 30 28 22 19 +96 89 87 81 78 79 +24 18 17 16 14 9 6 6 +40 33 28 25 23 21 20 16 +67 60 57 55 53 47 45 38 +48 50 53 56 57 60 62 59 +47 48 50 52 55 57 57 +34 35 37 38 41 42 45 49 +59 60 61 63 64 66 73 +42 45 47 50 49 51 53 +18 21 23 25 23 24 23 +30 33 32 33 36 38 39 39 +48 49 52 55 58 56 57 61 +54 57 56 57 62 +16 18 19 22 22 24 +74 77 80 81 82 82 79 +17 19 19 22 22 +27 29 31 32 32 33 36 40 +30 31 31 33 34 37 38 45 +77 80 81 82 84 88 89 +56 58 60 61 65 63 +86 88 92 95 95 +58 59 60 61 65 67 71 +55 57 58 62 64 66 73 +39 41 42 49 50 52 55 +8 11 18 21 22 24 26 24 +32 34 40 41 42 42 +35 36 38 41 48 51 55 +63 65 71 73 76 82 +89 88 89 91 92 94 +34 33 36 37 35 +65 64 65 66 69 70 71 71 +24 23 24 26 27 31 +10 9 12 13 14 17 20 25 +47 44 45 46 47 46 49 +51 48 50 47 44 +40 38 39 36 38 38 +75 73 74 71 73 77 +47 46 49 50 47 48 50 56 +12 10 10 12 15 17 +28 26 27 27 30 27 +10 7 10 10 11 13 15 15 +85 84 84 85 89 +35 32 33 35 35 38 44 +70 68 71 73 74 76 80 81 +75 72 76 77 79 80 83 82 +86 84 85 89 92 95 95 +12 9 11 13 16 17 21 25 +6 4 6 10 16 +36 35 37 40 43 50 53 56 +68 65 66 68 71 77 74 +85 83 86 93 95 96 97 97 +25 23 25 27 34 35 38 42 +41 38 45 47 48 54 +46 46 47 49 51 52 53 54 +30 30 33 34 36 37 36 +43 43 45 48 50 51 51 +87 87 89 92 96 +1 1 4 7 8 11 18 +91 91 94 96 99 97 99 +48 48 51 54 53 52 +73 73 76 77 80 82 80 80 +66 66 67 68 70 67 71 +72 72 70 71 77 +7 7 10 13 13 14 +73 73 73 76 79 77 +51 51 52 55 57 57 59 59 +15 15 16 16 20 +70 70 73 76 79 82 82 87 +19 19 23 26 27 29 +40 40 44 46 43 +6 6 9 13 15 18 18 +16 16 20 23 25 27 30 34 +72 72 75 77 79 83 90 +43 43 46 53 54 57 58 +5 5 6 11 13 10 +10 10 13 15 21 21 +29 29 30 37 39 43 +71 71 78 81 87 +45 49 50 51 52 54 +21 25 28 29 32 29 +38 42 43 46 46 +10 14 15 18 19 20 21 25 +10 14 17 18 19 22 23 29 +8 12 11 14 17 19 21 +58 62 61 62 61 +32 36 33 35 35 +1 5 6 4 8 +69 73 74 75 72 75 81 +54 58 59 59 61 +54 58 58 59 60 62 59 +61 65 65 68 71 74 74 +84 88 89 89 93 +51 55 56 56 58 59 60 65 +10 14 17 21 22 +13 17 20 21 25 26 25 +45 49 53 54 54 +80 84 88 90 91 94 98 +19 23 24 26 27 28 32 37 +42 46 48 54 55 +49 53 58 59 62 65 62 +60 64 70 73 75 75 +53 57 60 67 68 72 +27 31 33 35 41 44 51 +20 25 27 28 29 30 33 34 +37 42 45 46 44 +42 49 51 54 55 58 59 59 +36 42 44 47 50 52 56 +11 18 21 22 29 +77 82 79 81 82 +9 14 15 12 9 +37 44 41 43 43 +30 35 33 35 38 39 43 +45 52 53 55 57 59 58 64 +26 31 31 34 36 39 41 +38 43 44 45 47 50 50 49 +10 16 18 18 20 20 +18 24 25 28 29 29 31 35 +52 59 61 64 67 67 68 75 +18 25 26 29 32 33 37 38 +21 28 32 35 33 +24 31 35 36 38 41 41 +47 54 55 59 63 +60 66 70 71 74 75 80 +65 71 72 79 82 85 87 +59 65 66 72 70 +33 38 39 42 47 50 50 +22 29 30 31 33 34 39 43 +5 10 11 18 20 21 26 +91 89 88 85 84 85 +75 73 71 69 69 +23 21 19 17 15 13 12 8 +52 50 48 45 43 38 +34 33 32 31 32 29 26 +41 38 40 38 39 +72 70 69 72 72 +18 15 17 16 13 10 6 +86 85 82 83 77 +28 25 22 19 18 17 17 14 +95 92 92 91 89 91 +80 77 76 76 73 73 +23 20 18 18 17 15 14 10 +60 58 56 56 49 +23 21 17 15 14 +33 30 26 25 23 20 23 +97 96 93 89 89 +51 50 48 45 44 40 36 +84 82 80 79 75 72 71 64 +76 75 68 67 64 62 +97 94 88 86 89 +89 87 81 78 77 77 +97 94 91 86 83 81 80 76 +17 15 13 12 7 2 +24 27 25 23 20 19 17 16 +28 30 27 24 23 21 18 21 +8 9 8 7 6 5 2 2 +51 54 51 49 46 42 +41 43 41 38 36 31 +54 56 55 54 53 56 53 +68 71 69 70 67 65 67 +6 9 8 9 8 6 4 4 +51 53 51 49 47 49 48 44 +40 43 45 43 42 36 +49 50 50 47 45 42 40 38 +4 7 6 4 4 2 3 +98 99 99 98 98 +53 56 54 54 50 +81 82 79 79 77 71 +88 89 86 82 80 +55 58 56 54 51 47 44 45 +58 61 58 57 55 52 48 48 +28 29 28 24 23 19 +56 59 58 54 47 +85 88 86 79 76 +95 98 97 90 88 86 88 +52 53 50 49 47 42 41 41 +60 63 60 54 52 50 46 +55 57 56 55 49 48 45 39 +54 54 51 48 45 43 41 40 +60 60 57 54 53 55 +60 60 59 58 55 53 51 51 +44 44 41 40 36 +81 81 78 77 74 71 70 65 +46 46 43 46 44 +67 67 66 64 65 63 66 +74 74 72 69 66 64 67 67 +61 61 60 61 59 58 54 +48 48 46 48 47 44 39 +25 25 25 24 23 +88 88 88 86 88 +19 19 19 17 14 11 9 9 +70 70 67 65 65 64 60 +17 17 14 12 12 11 8 2 +99 99 96 92 90 +56 56 54 52 48 47 50 +80 80 77 73 72 69 69 +28 28 26 22 20 17 13 +70 70 66 64 58 +93 93 88 86 83 81 79 77 +40 40 34 31 34 +47 47 45 42 39 34 34 +89 89 82 79 78 74 +98 98 97 96 90 87 84 79 +47 43 41 38 35 34 32 29 +63 59 58 55 53 50 51 +80 76 74 71 68 65 65 +47 43 42 41 39 38 37 33 +84 80 77 75 74 67 +87 83 80 78 81 79 +18 14 16 13 16 +31 27 30 28 27 27 +15 11 8 11 9 6 2 +22 18 17 20 17 11 +52 48 47 44 44 41 40 +39 35 35 32 29 27 26 29 +50 46 45 45 43 42 40 40 +91 87 85 85 81 +56 52 50 50 43 +25 21 19 18 14 13 +78 74 70 69 67 69 +21 17 16 15 13 9 9 +59 55 54 51 47 43 +96 92 90 88 84 83 82 77 +49 45 40 37 35 +53 49 43 42 41 44 +50 46 44 38 35 35 +56 52 46 45 43 41 37 +46 42 40 37 30 25 +63 58 56 54 51 48 47 45 +55 50 49 48 47 44 47 +26 21 18 15 15 +65 58 57 55 53 49 +94 89 87 85 84 81 75 +65 59 57 55 56 55 +12 5 4 5 6 +24 17 20 17 17 +17 12 9 7 6 8 7 3 +44 37 39 36 30 +19 12 12 9 7 4 3 +99 94 92 89 87 87 90 +18 13 12 12 12 +65 60 60 58 54 +27 20 17 16 14 12 12 5 +22 15 11 10 8 +67 61 57 55 57 +37 32 29 28 25 21 21 +94 87 83 82 79 78 75 71 +60 54 51 47 44 38 +57 52 49 46 40 38 +84 79 78 73 70 72 +46 39 36 31 30 30 +85 80 79 73 71 67 +52 46 45 39 38 37 32 +76 78 76 74 69 68 66 66 +93 93 92 91 88 86 83 84 +2 1 3 5 8 6 +77 71 69 67 63 61 58 59 +17 10 7 6 6 +93 94 95 96 98 99 98 +66 71 72 74 78 81 +10 13 17 18 21 23 23 +48 48 45 43 37 30 +26 28 28 29 27 +93 91 90 92 95 95 +75 72 71 68 66 65 62 56 +36 40 42 43 46 45 44 +29 33 34 35 35 37 38 39 +20 25 26 28 30 32 36 34 +2 2 4 5 9 12 12 +59 63 66 70 70 +95 95 98 96 94 92 87 +63 56 54 52 55 49 +4 8 11 18 20 17 +54 56 53 51 48 50 47 +99 96 93 91 90 90 88 88 +39 39 41 43 45 49 +23 23 29 31 34 35 +62 58 55 53 46 41 +56 59 57 55 55 54 52 48 +47 50 53 54 55 57 58 +18 16 14 13 10 9 +26 29 31 34 36 39 +61 59 57 55 54 52 49 +34 35 37 39 41 42 44 +54 57 58 59 61 64 66 67 +24 23 22 19 16 15 +63 65 66 67 70 71 72 73 +97 96 93 90 87 84 81 +84 82 80 79 76 74 72 71 +21 23 24 26 28 30 32 33 +77 75 74 72 69 67 66 64 +65 67 70 72 75 77 79 +21 22 24 25 27 28 30 +77 79 81 82 83 +52 51 48 45 42 +21 20 17 15 14 11 10 +50 47 46 43 40 37 34 +50 52 53 56 59 61 63 +74 75 76 77 80 83 +85 86 87 89 90 92 94 96 +16 14 13 12 9 7 5 4 +92 89 86 85 82 81 78 +37 36 33 31 30 27 26 25 +55 53 51 50 48 46 44 41 +4 6 8 11 14 16 17 +31 34 36 37 40 +21 22 25 28 29 +26 28 30 33 35 38 41 +49 46 44 41 40 39 38 36 +66 67 69 72 75 +72 69 66 65 64 61 59 56 +88 91 92 95 98 +11 14 16 19 20 23 +64 62 61 59 58 56 55 53 +82 83 85 86 87 89 92 94 +91 88 85 84 82 +94 93 90 87 84 82 79 +11 14 15 16 19 +39 36 35 32 30 27 24 21 +79 80 81 84 87 +49 50 53 56 59 62 +41 40 39 38 37 +15 14 12 9 6 5 4 1 +9 11 13 15 18 19 20 +67 68 71 74 77 +86 89 92 93 94 97 98 +9 11 13 15 17 19 +81 83 85 88 91 92 +54 52 50 48 47 45 43 +25 24 22 20 19 +91 89 86 83 80 79 77 75 +22 21 19 18 15 14 +64 63 61 60 58 55 +14 17 19 22 24 26 +52 54 57 59 62 65 +11 12 14 17 20 21 +90 89 88 86 85 84 81 +81 82 84 87 89 92 93 +55 53 52 49 47 44 43 +28 26 24 23 21 19 18 17 +83 80 79 78 76 74 71 +95 92 89 86 83 +69 72 74 76 77 +51 54 57 59 62 64 67 +13 14 15 16 19 21 24 +47 46 44 43 41 40 37 36 +75 74 71 68 67 66 64 +30 33 34 36 38 40 41 43 +21 22 23 26 29 +32 35 36 37 38 40 43 45 +11 12 13 16 18 19 20 21 +20 18 16 15 13 10 9 8 +36 39 42 44 46 47 +53 51 49 47 44 43 40 +82 80 78 75 74 71 70 67 +26 25 22 21 20 19 18 17 +62 65 67 68 69 70 71 72 +85 84 81 79 78 77 75 74 +36 38 41 42 45 48 +56 54 53 50 49 48 +80 79 76 73 72 70 68 67 +40 38 37 34 31 +97 96 94 92 89 86 83 80 +62 59 58 56 54 52 +23 26 28 29 30 33 +12 15 17 18 21 22 25 +73 70 69 66 64 61 +34 32 30 29 26 23 +99 98 96 94 92 +67 70 72 74 75 76 +57 60 62 63 66 69 70 +76 74 72 69 68 67 66 63 +5 7 10 11 13 15 +36 38 41 44 46 +94 91 88 85 84 83 82 80 +13 15 16 17 19 22 25 26 +85 87 88 89 90 93 +19 17 16 15 13 10 8 5 +15 17 20 23 24 26 29 32 +93 92 91 88 85 83 80 +27 29 30 31 32 33 +68 70 71 72 74 77 80 +22 20 17 15 13 12 9 +23 20 18 15 14 12 +56 53 52 49 47 +19 16 14 11 10 +32 29 28 27 25 24 +98 96 93 90 88 +86 88 89 91 92 +69 66 65 62 60 59 +19 20 23 25 28 +56 57 60 63 65 68 70 72 +50 47 46 44 42 40 39 38 +54 53 52 50 49 46 44 +5 6 8 9 12 13 16 19 +38 41 43 44 47 50 +37 36 35 33 31 30 27 26 +73 76 78 81 83 84 85 +32 29 28 25 24 21 18 16 +84 86 87 89 91 94 95 +37 40 43 45 48 50 51 54 +91 93 94 96 97 +20 22 24 27 30 +56 59 60 63 64 +58 61 62 65 68 69 +43 40 37 36 34 31 28 26 +33 36 37 38 39 42 +49 47 45 43 42 41 39 38 +82 84 87 89 90 93 +26 23 20 18 17 +71 70 69 67 64 63 +67 69 72 73 74 +99 97 96 93 92 +38 41 42 43 44 45 48 +12 15 16 19 22 24 +72 74 76 79 82 84 85 87 +97 96 93 91 90 +55 52 50 48 47 46 +16 14 12 11 9 7 6 5 +99 96 94 91 88 87 85 83 +87 86 84 82 81 +13 14 15 16 19 21 23 +38 41 42 44 47 48 +19 18 17 16 13 10 +29 30 32 33 35 38 39 +35 34 33 31 30 +86 87 88 90 93 95 +35 32 31 29 27 +68 67 64 61 59 +80 77 74 72 71 +71 70 69 66 65 +15 17 18 19 20 21 +42 45 47 50 51 +33 31 29 28 27 25 24 +73 72 71 69 68 67 65 64 +43 46 48 51 53 54 +39 42 45 48 51 53 +53 52 50 49 47 +47 50 51 54 56 +26 29 30 33 36 37 40 42 +39 36 34 33 30 27 24 +65 66 68 70 72 75 76 77 +51 53 56 57 59 60 62 63 +53 52 50 48 47 45 44 +21 20 18 16 13 12 10 8 +84 85 88 90 92 93 +62 64 67 70 71 73 +33 34 37 40 41 42 +35 32 31 29 26 25 +9 10 13 15 16 18 20 23 +94 93 90 87 86 85 83 +12 9 8 6 5 3 2 +15 18 19 20 22 23 25 28 +96 94 93 90 88 86 85 +89 90 91 93 94 96 +77 76 74 73 70 +48 51 52 53 54 +32 29 27 26 25 +36 39 41 42 45 48 51 +48 50 52 53 54 56 59 +78 77 75 73 72 71 +82 81 78 77 74 73 72 71 +14 13 11 9 6 5 3 2 +69 72 75 77 80 82 83 +75 73 70 68 65 63 +91 89 87 85 82 81 78 76 +98 95 93 92 89 +74 72 69 67 64 62 61 +67 66 64 63 61 59 +73 71 69 68 66 +48 50 53 54 55 58 59 +38 41 43 46 47 49 50 +25 26 27 30 32 33 +62 64 66 67 69 71 72 +22 19 18 16 15 13 +40 38 36 35 34 32 +47 48 50 51 53 +26 29 31 33 35 38 39 +53 52 50 48 46 +57 58 59 62 65 +40 42 43 44 45 48 50 +10 12 14 17 20 +47 46 45 44 42 40 +70 71 73 75 76 78 81 +8 10 12 15 18 +50 51 52 54 56 58 59 +78 80 83 85 86 88 +89 86 85 84 83 81 +52 50 48 45 44 41 +54 51 48 47 46 +26 28 30 32 35 36 +56 59 61 63 66 69 70 +27 25 24 21 18 +79 80 81 84 87 90 93 +24 27 28 30 31 34 37 39 +9 10 13 15 17 +20 21 23 25 27 29 31 +42 39 36 33 31 30 28 27 +75 72 70 68 67 +38 37 34 31 28 +43 46 48 49 51 52 +38 39 41 43 45 +89 88 85 84 83 82 81 +42 39 38 35 33 31 +14 13 11 9 7 4 2 +39 41 42 43 45 46 48 +74 75 78 81 84 87 88 91 +65 68 70 71 73 +60 63 66 68 71 74 76 79 diff --git a/day2/main.go b/day2/main.go new file mode 100644 index 0000000..b999f8c --- /dev/null +++ b/day2/main.go @@ -0,0 +1,124 @@ +package main + +import ( + "fmt" + "strconv" + "strings" + + "git.mstar.dev/mstar/aoc24/util" + "git.mstar.dev/mstar/goutils/maputils" + "git.mstar.dev/mstar/goutils/other" + "git.mstar.dev/mstar/goutils/sliceutils" +) + +func parseLine(line string) []int { + strElems := sliceutils.Filter( + strings.Split(line, " "), + func(t string) bool { return len(t) > 0 }, + ) + return sliceutils.Map(strElems, func(t string) int { + return other.Must(strconv.Atoi(t)) + }) +} + +func generateCombinations(in []int) [][]int { + variations := [][]int{in} + + for pos := range len(in) { + tmp := []int{} + for i, v := range in { + if i == pos { + continue + } + tmp = append(tmp, v) + } + variations = append(variations, tmp) + } + + return variations +} + +func isSafe(in []int) bool { + isIncrementing := in[0] < in[1] + lastVal := in[0] + for _, elem := range in[1:] { + if util.AbsI(elem-lastVal) > 3 { + return false + } + if elem-lastVal == 0 { + return false + } + if isIncrementing && elem < lastVal || !isIncrementing && elem > lastVal { + return false + } + lastVal = elem + } + return true +} + +func main() { + lines := util.FileContentToNonEmptyLines(util.LoadFileFromArgs()) + safeLines1 := map[int]bool{} + + for i, line := range lines { + elems := parseLine(line) + safeLines1[i] = isSafe(elems) + } + filteredTask1 := maputils.FilterMap(safeLines1, func(k int, v bool) bool { + return v + }) + fmt.Printf("Task 1: %d\n", len(filteredTask1)) + + safeLines2 := map[int]bool{} + for i, line := range lines { + elems := parseLine(line) + variations := generateCombinations(elems) + for _, variation := range variations { + if isSafe(variation) { + safeLines2[i] = true + } + } + } + filteredTask2 := maputils.FilterMap(safeLines2, func(k int, v bool) bool { + return v + }) + fmt.Printf("Task 2: %d\n", len(filteredTask2)) +} + +/* for _, elem := range elems[1:] { + if util.AbsI(elem-lastVal) > 3 { + // fmt.Printf("Line %d failed max diff with a value of %d\n", i, util.AbsI(elem-lastVal)) + if !firstDiscordDone { + // fmt.Printf("Discard for line %d used up\n", i) + firstDiscordDone = true + continue + } + fmt.Printf("Line %d failed max diff with a value of %d\n", i, util.AbsI(elem-lastVal)) + log.Printf("%d: %s\n", i, line) + continue lineloop2 + } + if elem-lastVal == 0 { + // fmt.Printf("Line %d failed no equal vals\n", i) + if !firstDiscordDone { + // fmt.Printf("Discard for line %d used up\n", i) + firstDiscordDone = true + continue + } + log.Printf("%d: %s\n", i, line) + fmt.Printf("Line %d failed no equal vals\n", i) + continue lineloop2 + } + if isInc && elem < lastVal || !isInc && elem > lastVal { + // fmt.Printf("Line %d failed same directionm\n", i) + if !firstDiscordDone { + // fmt.Printf("Discard for line %d used up\n", i) + firstDiscordDone = true + continue + } + log.Printf("%d: %s\n", i, line) + fmt.Printf("Line %d failed same directionm\n", i) + continue lineloop2 + } + lastVal = elem +} +*/ diff --git a/day2/sample b/day2/sample new file mode 100644 index 0000000..b49c10d --- /dev/null +++ b/day2/sample @@ -0,0 +1,6 @@ +7 6 4 2 1 +1 2 7 8 9 +9 7 6 2 1 +1 3 2 4 5 +8 6 4 4 1 +1 3 6 7 9 diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..130153d --- /dev/null +++ b/go.mod @@ -0,0 +1,7 @@ +module git.mstar.dev/mstar/aoc24 + +go 1.23.3 + +require git.mstar.dev/mstar/goutils v1.5.4 + +require github.com/BooleanCat/go-functional/v2 v2.3.0 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..7b82a65 --- /dev/null +++ b/go.sum @@ -0,0 +1,8 @@ +git.mstar.dev/mstar/goutils v1.5.3 h1:Wqa8H8EWnc9IJmzsi6qeVqwYHPvWiDhG/b9WtZr0Nos= +git.mstar.dev/mstar/goutils v1.5.3/go.mod h1:juxY0eZEMnA95fedRp2LVXvUBgEjz66nE8SEdGKcxMA= +git.mstar.dev/mstar/goutils v1.5.4 h1:l/4oQe/fBk9zyXplQkGXbmQndnm0aRdHuy4wgQfNrFo= +git.mstar.dev/mstar/goutils v1.5.4/go.mod h1:juxY0eZEMnA95fedRp2LVXvUBgEjz66nE8SEdGKcxMA= +github.com/BooleanCat/go-functional/v2 v2.3.0 h1:mwVrUa4MSKQNs/N4EPy0fadRLyzP+eoc0NbnzWHEzLM= +github.com/BooleanCat/go-functional/v2 v2.3.0/go.mod h1:IpUUAXAc9CiWDb+YDXkJyyUhtOVqDtyICDRg/de1IaQ= +gitlab.com/mstarongitlab/goutils v1.5.1 h1:UlQL90DctJ7QbfJ5NOPheMK3PdFt6sBIjXR3fJpd3Ms= +gitlab.com/mstarongitlab/goutils v1.5.1/go.mod h1:f71xLeTv05GHiRHKkgDRXfxOPRkjXNteXqLZyg02xhs= diff --git a/util/loadFile.go b/util/loadFile.go new file mode 100644 index 0000000..70ced59 --- /dev/null +++ b/util/loadFile.go @@ -0,0 +1,35 @@ +package util + +import ( + "flag" + "os" + "strings" + + "git.mstar.dev/mstar/goutils/sliceutils" +) + +func LoadFileFromArgs() []byte { + if !flag.Parsed() { + flag.Parse() + } + data, err := os.ReadFile(flag.CommandLine.Arg(0)) + if err != nil { + panic(err) + } + return data +} + +func AbsI(a int) int { + if a > 0 { + return a + } else { + return -a + } +} + +func FileContentToNonEmptyLines(data []byte) []string { + return sliceutils.Filter( + strings.Split(string(data), "\n"), + func(t string) bool { return len(t) > 0 }, + ) +}