From b281d8e39b7512a9d9707cc6438496eedb4aae0f Mon Sep 17 00:00:00 2001 From: Akshay Mankar Date: Sat, 9 Dec 2023 13:10:44 +0100 Subject: [PATCH] [haskell] Day 7 --- haskell/aoc2023.cabal | 1 + haskell/app/Main.hs | 2 + haskell/src/Day7.hs | 259 +++++++++++ input/day7 | 1000 +++++++++++++++++++++++++++++++++++++++++ input/day7-eg | 5 + 5 files changed, 1267 insertions(+) create mode 100644 haskell/src/Day7.hs create mode 100644 input/day7 create mode 100644 input/day7-eg diff --git a/haskell/aoc2023.cabal b/haskell/aoc2023.cabal index 4f1a2fb..6045d6a 100644 --- a/haskell/aoc2023.cabal +++ b/haskell/aoc2023.cabal @@ -26,6 +26,7 @@ library , Day4 , Day5 , Day6 + , Day7 executable aoc2023 import: warnings diff --git a/haskell/app/Main.hs b/haskell/app/Main.hs index 510e464..c2ac10c 100644 --- a/haskell/app/Main.hs +++ b/haskell/app/Main.hs @@ -8,6 +8,7 @@ import Day3 qualified import Day4 qualified import Day5 qualified import Day6 qualified +import Day7 qualified import System.Environment (getArgs) main :: IO () @@ -19,4 +20,5 @@ main = do ["day4"] -> Day4.run ["day5"] -> Day5.run ["day6"] -> Day6.run + ["day7"] -> Day7.run args -> error $ "Invlaid args: " <> show args diff --git a/haskell/src/Day7.hs b/haskell/src/Day7.hs new file mode 100644 index 0000000..35e38d6 --- /dev/null +++ b/haskell/src/Day7.hs @@ -0,0 +1,259 @@ +{-# LANGUAGE LambdaCase #-} + +module Day7 where + +import Control.Monad (replicateM) +import Data.Char (isDigit) +import Data.Functor ((<&>)) +import Data.List (sort, sortBy) +import Data.Map.Lazy qualified as Map +import Data.Ord (comparing) +import Text.ParserCombinators.ReadP +import Data.Function (on) + +run :: IO () +run = do + input <- readInput + putStrLn $ "Part 1 Answer: " <> show (part1 input) + putStrLn $ "Part 2 Answer: " <> show (part2 input) + +part1 :: [(Hand, Bid)] -> Int +part1 handsWithBids = + let sortedHandsWithBids = sort handsWithBids + in sum $ zipWith (\(_, bid) rank -> bid * rank) sortedHandsWithBids [1 ..] + +part2 :: [(Hand, Bid)] -> Int +part2 handsWithBids = + let sortedHandsWithBids = sortBy (jokerCompare `on` fst) handsWithBids + in sum $ zipWith (\(_, bid) rank -> bid * rank) sortedHandsWithBids [1 ..] + +-- | Order of the constructors is important +-- +-- >>> HighCard `compare` FiveOfAKind +-- LT +-- +-- >>> FullHouse `compare` ThreeOfAKind +-- GT +data HandType + = HighCard + | OnePair + | TwoPair + | ThreeOfAKind + | FullHouse + | FourOfAKind + | FiveOfAKind + deriving (Eq, Ord, Show) + +-- | +-- >>> handType $ Hand [K,K,K,K,K] +-- FiveOfAKind +-- +-- >>> handType $ Hand [C2,C2,C2,C2,K] +-- FourOfAKind +-- +-- >>> handType $ Hand [K,J,K,C2,J] +-- TwoPair +-- +-- >>> handType $ Hand [K,A,J,Q,A] +-- OnePair +-- +-- >>> handType $ Hand [A,J,A,C2,A] +-- ThreeOfAKind +-- +-- >>> handType $ Hand [A,A,A,K,K] +-- FullHouse +handType :: [Card] -> HandType +handType cards = + let counts = foldr (\c -> Map.insertWith (+) c (1 :: Int)) mempty cards + in case maximum counts of + 1 -> HighCard + 2 + | length (Map.filter (== 2) counts) == 2 -> TwoPair + | otherwise -> OnePair + 3 + | 2 `elem` counts -> FullHouse + | otherwise -> ThreeOfAKind + 4 -> FourOfAKind + 5 -> FiveOfAKind + _ -> error "Too many cards" + +-- | +-- >>> jokerHandType [J,J,J,J,J] +-- FiveOfAKind +-- +-- >>> jokerHandType [Q,Q,Q,Q,Q] +-- FiveOfAKind +-- +-- >>> jokerHandType [Q,Q,Q,Q,J] +-- FiveOfAKind +-- +-- >>> jokerHandType [Q,Q,Q,J,J] +-- FiveOfAKind +-- +-- >>> jokerHandType [Q,Q,Q,K,J] +-- FourOfAKind +-- +-- >>> jokerHandType [Q,Q,A,K,J] +-- ThreeOfAKind +-- +-- >>> jokerHandType [Q,Q,A,A,J] +-- FullHouse +-- +-- >>> jokerHandType [Q,Q,Q,A,A] +-- FullHouse +-- +-- >>> jokerHandType [Q,Q,A,K,K] +-- TwoPair +-- +-- >>> jokerHandType [T,J,Q,K,A] +-- OnePair +-- +-- >>> jokerHandType [T,J,J,K,A] +-- ThreeOfAKind +jokerHandType :: [Card] -> HandType +jokerHandType cards = + let jokers = length $ filter (== J) cards + withoutJokers = filter (/= J) cards + in case length withoutJokers of + 0 -> FiveOfAKind + 5 -> handType withoutJokers + _ -> + let countsWithoutJoker = foldr (\c -> Map.insertWith (+) c (1 :: Int)) mempty withoutJokers + pairsCount = Map.size (Map.filter (== 2) countsWithoutJoker) + in case maximum countsWithoutJoker of + 5 -> FiveOfAKind + 4 + | jokers == 1 -> FiveOfAKind + | otherwise -> FourOfAKind + 3 + | jokers == 2 -> FiveOfAKind + | otherwise -> FourOfAKind + 2 + | jokers == 3 -> FiveOfAKind + | jokers == 2 -> FourOfAKind + | jokers == 1 && pairsCount == 2 -> FullHouse + | otherwise -> ThreeOfAKind + 1 + | jokers == 4 -> FiveOfAKind + | jokers == 3 -> FourOfAKind + | jokers == 2 -> ThreeOfAKind + | otherwise -> OnePair + _ -> error "too many cards" + +-- Order of the constructors is important +data Card + = C2 + | C3 + | C4 + | C5 + | C6 + | C7 + | C8 + | C9 + | T + | J + | Q + | K + | A + deriving (Eq, Ord, Show) + +instance JokerOrd Card where + jokerCompare :: Card -> Card -> Ordering + jokerCompare J J = EQ + jokerCompare J _ = LT + jokerCompare _ J = GT + jokerCompare c1 c2 = c1 `compare` c2 + +newtype Hand = Hand [Card] + deriving (Eq) + +instance Show Hand where + show :: Hand -> String + show (Hand cardOrder) = + foldMap + ( \c -> + case show c of + ['C', x] -> [x] + xs -> xs + ) + cardOrder + +class JokerOrd a where + jokerCompare :: a -> a -> Ordering + +instance (JokerOrd a) => JokerOrd [a] where + jokerCompare [] [] = EQ + jokerCompare [] _ = LT + jokerCompare _ [] = GT + jokerCompare (x : xs) (y : ys) = + let comparison = jokerCompare x y + in if comparison == EQ + then jokerCompare xs ys + else comparison + +-- | +-- >>> Hand [K,K,K,K,K] `compare` Hand [A,A,A,A,A] +-- LT +-- +-- >>> Hand [K,K,K,K,A] `compare` Hand [T,T,T,T,T] +-- LT +instance Ord Hand where + compare :: Hand -> Hand -> Ordering + compare (Hand cards1) (Hand cards2) = + case comparing handType cards1 cards2 of + EQ -> cards1 `compare` cards2 + x -> x + +instance JokerOrd Hand where + jokerCompare :: Hand -> Hand -> Ordering + jokerCompare (Hand cards1) (Hand cards2) = + case comparing jokerHandType cards1 cards2 of + EQ -> jokerCompare cards1 cards2 + x -> x + +type Bid = Int + +readInput :: IO [(Hand, Bid)] +readInput = do + input <- getContents + case readP_to_S inputParser input of + [] -> error "Parser failed" + [(parsed, "")] -> pure parsed + xs -> error $ "Parser failed: " <> show xs + +cardParser :: ReadP Card +cardParser = + satisfy (`elem` "23456789TJQKA") <&> \case + '2' -> C2 + '3' -> C3 + '4' -> C4 + '5' -> C5 + '6' -> C6 + '7' -> C7 + '8' -> C8 + '9' -> C9 + 'T' -> T + 'J' -> J + 'Q' -> Q + 'K' -> K + 'A' -> A + c -> error $ "impossible card: " <> [c] + +handParser :: ReadP Hand +handParser = + Hand <$> replicateM 5 cardParser + +bidParser :: ReadP Bid +bidParser = do + read <$> munch1 isDigit + +lineParser :: ReadP (Hand, Int) +lineParser = do + h <- handParser + skipSpaces + b <- bidParser + pure (h, b) + +inputParser :: ReadP [(Hand, Int)] +inputParser = do + sepBy1 lineParser (char '\n') <* eof diff --git a/input/day7 b/input/day7 new file mode 100644 index 0000000..12796c0 --- /dev/null +++ b/input/day7 @@ -0,0 +1,1000 @@ +8T64Q 595 +79J27 258 +88885 88 +8933J 444 +72527 676 +5555T 788 +69946 463 +572QQ 827 +553JQ 932 +99T99 567 +47Q7Q 112 +8J8QQ 186 +5K499 862 +2837Q 321 +55557 310 +KAAAA 263 +J4999 783 +4QQQ4 961 +64464 329 +8AQ9K 153 +763AK 341 +Q3K3Q 353 +4TJT6 593 +KJ46J 666 +AA92Q 176 +88555 738 +8KJJJ 431 +46T35 295 +86868 400 +884A4 19 +QQK44 860 +99996 794 +6J778 159 +45Q9T 763 +8AQAQ 39 +4JJ2K 764 +Q42AT 3 +77Q7Q 905 +57ATJ 185 +QQQJ6 707 +TKT2T 115 +JK646 951 +3KT2K 324 +94J64 569 +Q278J 998 +36QKA 979 +89T98 772 +55T66 669 +62747 161 +742TK 264 +J5A2Q 252 +JKAJK 455 +72777 659 +4454T 940 +Q2278 479 +63K36 53 +3K839 512 +A5AA5 223 +T3332 27 +KQ55Q 217 +75TT7 706 +53555 775 +9KK96 348 +9A999 984 +9TT99 943 +TTATJ 906 +6964K 711 +42452 983 +22AA2 241 +22282 521 +77733 627 +KQA47 987 +738J7 963 +KK2KK 231 +22322 709 +4T7J6 665 +Q6K6A 417 +2479K 955 +7J22T 861 +77A4A 446 +8642K 934 +25J32 435 +A3A3A 883 +QQ3JQ 280 +K7666 489 +2QAQ9 732 +85422 976 +T3393 322 +28888 298 +J9759 608 +33438 564 +A3KQ4 377 +2K6TJ 209 +QQ64J 482 +8T5T3 815 +3K6K6 123 +37757 741 +555A6 858 +5TAAA 12 +2225K 965 +Q29QQ 355 +2277K 62 +99932 169 +77722 458 +Q9444 550 +KJ8KK 338 +9K99A 238 +5Q5Q2 427 +7A6A6 675 +798AQ 766 +386K8 420 +88788 681 +2K4JK 974 +53426 776 +46892 884 +7Q47T 754 +923A4 719 +449JQ 506 +2Q2Q2 596 +K888T 235 +6AA6K 232 +57T5T 314 +T3TA4 171 +3QQ4A 581 +TAA98 946 +75Q8A 170 +46A4A 807 +36836 539 +888T3 515 +5KA55 520 +92J56 164 +Q3J56 1 +KAAJ7 499 +7QJQ4 196 +TTKTK 552 +AQ4QA 257 +7JTTT 249 +7QQ89 268 +96998 733 +39933 713 +44JJ4 603 +6877K 206 +K224J 450 +TTTKJ 38 +T7999 22 +7T55J 660 +66363 61 +33363 610 +TTAAT 795 +36336 739 +55255 604 +982JJ 146 +9ATQ6 313 +TT688 293 +TT7KT 648 +93298 817 +7TJ77 288 +23J3J 184 +JT7T3 132 +Q9Q95 430 +5554A 14 +QAQQA 212 +TT33T 538 +7A7J7 97 +JQ738 968 +AKA8K 923 +K9988 498 +J424A 481 +5AT66 792 +QQ444 835 +22262 916 +TJTTJ 334 +77Q47 462 +84884 871 +959AQ 950 +9637J 492 +QKQQ3 214 +68K6A 13 +26624 843 +TTTT4 470 +48TT5 81 +A6AQA 540 +TTQ9Q 285 +A8AAA 473 +88848 900 +K779K 688 +3QJJ5 852 +66T6K 224 +55595 720 +2222T 784 +83QT5 870 +6QQQ2 426 +44K55 625 +4AJ94 472 +6A55A 284 +85584 43 +Q96J2 986 +KA5AA 939 +62662 74 +89277 390 +4JKKJ 349 +336AA 82 +A99A9 477 +Q95J9 116 +K99K8 108 +AKA6A 505 +37J92 800 +TT98T 15 +JA75Q 276 +44433 91 +93494 684 +7A772 220 +K6JKA 9 +8TT85 685 +44448 600 +64T6T 484 +A3K29 547 +4455T 698 +932J6 742 +57595 198 +937QJ 114 +69696 423 +A3A55 143 +K8J4J 25 +7AQ64 646 +8Q44A 166 +J2AQA 809 +9993Q 272 +A6JT4 812 +K44T4 222 +J5567 577 +22244 109 +TKTTT 631 +Q678K 919 +Q9KT3 157 +4AJ64 602 +7667T 912 +A9K35 282 +272A2 78 +J887J 113 +K9A57 246 +JA7A2 915 +A3T9A 73 +264T4 129 +KK777 386 +T6665 507 +JT2AT 642 +66K66 382 +J4666 94 +235KQ 966 +T3T53 868 +3QA4A 584 +QQ7QQ 432 +JKK6K 37 +64594 575 +95669 931 +37383 366 +K9KKJ 563 +4Q9T3 970 +8688T 180 +Q999Q 242 +74724 243 +6666A 623 +66AT6 250 +4KA58 451 +J622J 493 +2J32T 47 +Q4586 859 +3393Q 221 +9Q55Q 908 +66277 121 +T7A94 461 +8KT58 160 +K9K99 989 +29292 23 +48462 574 +6T443 1000 +33344 414 +22728 964 +Q58JQ 680 +35K7T 542 +5A3QK 673 +A5553 453 +84Q7T 743 +9489J 903 +TJT94 5 +2925A 195 +45954 17 +J6T79 460 +6638J 848 +977J9 192 +AAAJ5 131 +3T39T 401 +87828 447 +9JJK7 651 +42552 632 +T7TJJ 389 +AA75A 274 +KA46K 11 +Q2Q2Q 55 +KJKK3 697 +5K3K3 495 +84786 21 +5J5QQ 413 +25755 849 +29222 780 +J5A9K 630 +K6TA6 863 +AKKKJ 395 +Q4456 777 +547K7 328 +QT35K 559 +AJAA4 872 +KTJ6K 48 +TQQTQ 215 +22662 768 +28547 526 +7J77Q 958 +2J2JK 42 +AK648 691 +K6833 716 +55J55 888 +33322 904 +2A6J7 605 +58887 586 +4J8Q7 621 +9A8Q8 824 +JQ2T9 356 +3TTTT 383 +JQQQJ 699 +56T3Q 351 +22422 879 +K25AJ 585 +82J66 305 +QJQ68 703 +96974 189 +4JT36 419 +84TJ2 549 +A95A2 84 +KK3KK 724 +A5KKA 421 +TTTAT 636 +2T22K 822 +337J7 634 +98TT9 770 +J99JJ 167 +88454 236 +J2985 405 +KQKKK 798 +6KQ82 168 +AJJ9A 92 +95595 150 +82943 672 +9Q7JA 69 +43QJQ 829 +A8382 773 +332J4 8 +7777K 657 +9J999 851 +35J5J 99 +AKQ82 24 +59355 658 +AAAQA 452 +98888 44 +77947 476 +48222 533 +T6666 30 +TT4T7 144 +3Q8Q8 297 +J3888 309 +QJ22A 933 +6TQ88 977 +23A4J 18 +66A5A 262 +6T5A5 914 +5K9J6 922 +Q4Q99 751 +3874Q 60 +TTKT8 653 +7TT7T 126 +9J668 364 +9ATK2 155 +44462 187 +85AJA 692 +K54J9 594 +2TK95 318 +QT289 744 +AQ45Q 846 +K2583 841 +55556 837 +76662 286 +79577 893 +K3J47 140 +QAT37 644 +89QT7 921 +3AAAA 379 +K49K8 647 +7373Q 396 +9J5Q8 254 +799Q7 85 +5J55K 558 +TJ254 528 +Q5QJQ 207 +23223 527 +AQ83K 694 +9TJ2J 101 +9476K 590 +TTQ5J 359 +A9TQ2 641 +2J35Q 519 +55522 398 +99949 708 +94K3K 234 +4J884 336 +3T32T 633 +33J3K 137 +8J778 456 +8Q57T 726 +79975 177 +J37Q2 467 +TKKKT 553 +47442 992 +AT7K3 875 +76666 573 +424QJ 497 +333K8 597 +AJTAA 29 +89Q26 844 +3KK33 723 +A9AKJ 138 +77555 592 +33888 762 +T5342 561 +75547 190 +TT4JT 650 +45Q55 818 +7J777 935 +333TQ 478 +566J4 71 +T7QTT 854 +28558 643 +26895 273 +8762A 58 +J333J 79 +387J4 437 +T9926 980 +4K425 325 +97Q5K 546 +Q57K3 898 +AA988 579 +669JA 678 +859J5 701 +29992 700 +JA66A 141 +4J777 440 +J7A7A 816 +JQQ96 941 +43354 924 +66T22 408 +49444 865 +6KA5A 649 +Q5T28 106 +77977 352 +J56Q5 31 +22656 814 +AT333 518 +6JTT6 2 +99889 838 +JAKAK 790 +35355 247 +T2A82 32 +68888 429 +Q69T3 944 +8688K 72 +684K8 337 +T9576 385 +333A4 674 +3T633 994 +92JQK 894 +A6293 517 +KK288 327 +373Q4 66 +KKJJ8 737 +38T67 995 +KKJ4K 609 +95898 615 +AQQA9 802 +TT8J7 67 +3A438 397 +AJAKJ 895 +254A2 808 +J9T26 117 +AJAAJ 954 +94499 847 +T8999 836 +K4T7J 529 +24444 535 +J2222 956 +44KA4 45 +6A66A 95 +52778 856 +JKJKK 346 +AAJAA 211 +J52J5 103 +786JJ 693 +Q66J6 876 +5353J 511 +KK6K6 438 +K9Q99 424 +948T9 655 +K47KK 380 +97937 271 +KKK4K 617 +J4978 142 +7Q848 149 +8733J 312 +88778 172 +6A363 926 +KQQ4K 468 +AK9Q7 962 +9TQ58 436 +KJK57 165 +KA464 967 +8TTQQ 10 +7464K 306 +558Q7 583 +29999 267 +QAA82 656 +K6A75 760 +7775J 442 +KJ3K3 332 +JQ2T4 128 +T9728 350 +J4494 89 +498TT 365 +AJA4Q 193 +666Q4 806 +37476 410 +896QK 302 +KKJ6Q 614 +29522 265 +5TA48 287 +AJ24T 705 +76TK2 173 +A2749 261 +J9575 433 +KQ948 828 +59545 952 +3AT56 275 +664Q8 182 +6429T 554 +QQ8QQ 406 +24AA4 259 +5J66J 315 +9338Q 981 +66637 503 +TT888 354 +23243 179 +6K54J 804 +277J3 855 +22727 682 +3693Q 64 +97489 375 +57T88 174 +TQA36 428 +KK5KK 839 +Q343Q 589 +A2262 628 +A9AJA 373 +56757 565 +3K333 454 +96622 233 +JJJ8J 370 +9KTTT 466 +K22JK 702 +KKK33 508 +T9T9T 715 +99595 368 +TJT55 485 +J28T8 591 +T8768 291 +T7K68 845 +J666J 663 +Q966J 105 +J3333 360 +8AQA3 496 +KJTQK 316 +KTTT3 372 +A259T 181 +7777Q 191 +78777 911 +7A925 208 +QAQKQ 930 +Q736K 747 +K7KTK 920 +388T3 982 +Q5QQQ 218 +49J49 145 +23329 219 +K97KQ 736 +7KQJ7 667 +4KJA6 323 +422T2 857 +KJJKT 746 +T7TTT 727 +J552T 304 +77TKK 107 +K432J 278 +9JJ99 988 +6Q8A8 283 +2A6T8 890 +28AA5 601 +T662T 721 +55J5J 725 +4QTQ4 237 +TKK4T 175 +22682 471 +J8538 343 +498J3 910 +3T548 850 +33868 465 +K55K3 151 +947KJ 118 +3T9A5 281 +4T83K 422 +22K27 51 +J777J 80 +A8579 199 +K5AK5 972 +77233 867 +J8J88 938 +22TJ9 369 +757A8 686 +93J2Q 758 +A79T6 999 +J6KA9 239 +J4444 378 +QJJ62 59 +JQ6Q3 928 +KK888 543 +J636J 4 +9AA3A 599 +69J6J 582 +6JKJK 110 +Q77QQ 244 +Q7272 866 +2346J 689 +868J8 892 +969J9 500 +5T5K5 619 +27622 937 +99799 901 +KK336 205 +J5566 975 +2A955 947 +TKQ57 52 +99995 618 +36223 301 +T4TT8 90 +A99AA 49 +29699 969 +84QTJ 449 +3T99J 801 +TQQQQ 96 +TTK99 344 +2J282 98 +7TT79 152 +J7JJ7 480 +A288J 393 +888J8 411 +689K6 294 +4T2J4 787 +Q3344 307 +2A7TA 611 +7J86Q 624 +69J85 869 +37878 771 +355QA 292 +5757J 357 +844Q8 156 +8TTTT 416 +QK9KQ 299 +4A6K5 757 +76777 68 +K692K 710 +QJ853 813 +2JJ2J 256 +7TTKK 957 +9JK9K 56 +4A55A 303 +K6K22 228 +99747 767 +6K839 560 +JA4TA 248 +JA822 459 +J6428 668 +KKT9K 677 +A7AAA 65 +38333 796 +664Q3 120 +J7432 36 +A356J 111 +73Q49 475 +86TJ2 899 +24442 864 +55444 729 +7K6K4 753 +7269Q 960 +77J6J 194 +8K694 210 +5338J 544 +TT99J 745 +55T5T 622 +33Q33 367 +55558 342 +737J4 148 +6T6J9 613 +3AA2T 296 +434J6 319 +333T3 690 +44848 936 +A98A9 638 +7K254 670 +74AJQ 104 +69698 266 +76477 821 +TQJTT 580 +4TKK4 909 +45555 474 +53QQ5 887 +QJA3Q 443 +94A85 136 +3KAAA 913 +39999 403 +A4J4Q 825 +28T5A 874 +ATTA4 54 +43JJ4 226 +T9J48 509 +K7T23 945 +AT2Q8 557 +6Q7J4 789 +KKK9K 16 +93J79 317 +79653 200 +Q666Q 335 +AQ33A 362 +A999J 765 +5QT47 441 +JQQQT 756 +9T325 122 +4AQ8T 571 +TQ342 70 +222JK 779 +JA443 300 +J7K88 990 +646T6 154 +95569 842 +4J626 384 +44KK4 50 +JQQQQ 93 +AA6AA 735 +99888 929 +4KK9K 629 +A38K2 75 +AA2AA 163 +QQKQQ 87 +8Q56K 578 +QK467 740 +94329 687 +257A6 695 +K9929 345 +777A7 645 +QA9AA 57 +KKAAA 959 +5T5T9 188 +8JTTJ 33 +2KKAQ 371 +47747 671 +28538 202 +TJ38A 881 +656A5 491 +54Q89 134 +8Q888 704 +AKAKK 415 +J2Q92 524 +23859 347 +8K7A6 20 +JK676 826 +555K5 833 +9AK54 490 +JT658 793 +79KQ4 778 +JA7K2 229 +88883 840 +87778 791 +799K7 712 +4KKKA 487 +T6JTT 537 +ATQK2 76 +Q5679 392 +7QKQ7 147 +8KKKK 568 +772J6 363 +58545 41 +A89KT 696 +Q3T86 616 +QAK54 289 +33334 86 +2AAA2 158 +A55A5 83 +TAAT5 102 +Q9673 46 +9KKK8 882 +6JA46 486 +6A254 277 +JTTK2 556 +J76Q2 269 +9Q888 781 +J4K4K 100 +TAATA 488 +AA9AA 598 +78TQ3 722 +A888A 260 +T675Q 34 +T3T33 761 +Q32AQ 35 +4QA45 820 +87AAA 635 +QAA3K 516 +J5543 683 +64546 404 +74T67 464 +3QT3T 731 +7TT77 978 +7J77K 402 +AAKQ4 7 +349TA 251 +682QA 917 +4357T 245 +75KT6 183 +4QQ54 652 +25QK8 358 +95KKA 996 +66556 407 +ATTKK 494 +666JK 612 +3JK5K 290 +426J2 522 +JA59J 823 +5755T 308 +JTAQK 831 +T52Q9 769 +5JKKK 387 +8QKKK 333 +5K59K 541 +44454 942 +64625 530 +JK7T9 361 +2TQQQ 270 +42AK6 997 +83T87 532 +942AQ 785 +KAQQK 993 +44666 750 +43KQ8 418 +KJ522 749 +JQQ77 953 +22J26 119 +7TK6Q 531 +8TAK6 127 +44QQ3 63 +63236 853 +66A9A 873 +K3J3T 805 +73373 797 +3J336 902 +TT67T 896 +88KKK 810 +KKKQJ 139 +69Q58 718 +9AKQ5 501 +3223J 948 +55AJA 588 +99K59 434 +86568 755 +T25AT 897 +Q2532 502 +38383 388 +J2A98 832 +4TA4A 606 +32888 730 +J9TJA 545 +3328J 339 +5TTT5 907 +J3AAJ 819 +59459 880 +99933 255 +3K762 834 +9T729 448 +58885 376 +94449 6 +J7767 374 +KKT27 203 +QQJQA 133 +A4K82 326 +TTTK4 803 +5789J 661 +67633 394 +J37KK 197 +55Q57 204 +455Q2 562 +TQ539 626 +JJ222 714 +JJJJJ 728 +98599 225 +K666K 971 +QKKK7 878 +A8888 664 +99JKJ 213 +Q332Q 774 +5J525 130 +77377 786 +3KAT4 637 +48A9A 891 +7K737 409 +J8Q89 525 +TT898 877 +3Q888 534 +JTA8A 886 +J57J8 991 +9TKA5 555 +76Q27 412 +72977 504 +488TK 830 +2K748 162 +T74T9 566 +K475J 425 +KK62K 889 +AJ4TT 510 +578KT 124 +666J6 570 +74968 331 +2T265 620 +67677 439 +AAJ79 949 +88339 799 +AJQ9A 927 +J34T3 523 +929KK 551 +2479Q 227 +KKJKK 918 +85445 201 +9Q7J6 536 +47454 513 +A2A4Q 607 +A648J 759 +A97A7 514 +J86AA 240 +Q6374 576 +4J3Q5 26 +35A75 178 +46KQ4 734 +842A2 457 +AA4A4 885 +724Q5 925 +977J8 654 +TTT5T 662 +J3339 679 +67J67 548 +QTJJ6 28 +QTAAJ 330 +TTJTT 216 +7A5A7 483 +5JJ8A 973 +53AK4 639 +KKKJT 640 +43825 782 +K5KK5 381 +7QT77 77 +99777 40 +777K8 752 +2QQ77 811 +J75TQ 320 +9K552 445 +A65QA 125 +Q2379 469 +74A98 253 +69969 340 +QKT84 748 +TTQQ7 230 +74QJT 985 +57757 311 +Q7T27 587 +Q8Q99 135 +6K854 279 +3TKAA 717 +77484 391 +Q2K24 399 +Q7QQJ 572 \ No newline at end of file diff --git a/input/day7-eg b/input/day7-eg new file mode 100644 index 0000000..bf2815e --- /dev/null +++ b/input/day7-eg @@ -0,0 +1,5 @@ +32T3K 765 +T55J5 684 +KK677 28 +KTJJT 220 +QQQJA 483 \ No newline at end of file