├── day07 ├── README.md ├── Setup.hs ├── day02.txt ├── day07.cabal ├── input.txt ├── stack.yaml ├── day05.txt └── src │ └── day07.hs ├── day02 ├── day02 ├── input.txt └── day02.hs ├── day01 ├── day01_1.hs ├── day01_2.hs └── input.txt ├── stack.yaml.lock ├── day06 ├── stack.yaml.lock ├── day06.hs ├── stack.yaml └── input.txt ├── day07_old ├── stack.yaml.lock ├── input.txt ├── stack.yaml └── day07.hs ├── .gitignore ├── day04 └── day04.hs ├── stack.yaml ├── day05 ├── input.txt └── day05.hs └── day03 ├── input.txt └── day03.hs /day07/README.md: -------------------------------------------------------------------------------- 1 | # day07 2 | -------------------------------------------------------------------------------- /day07/Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /day02/day02: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tclv/aoc2019/master/day02/day02 -------------------------------------------------------------------------------- /day01/day01_1.hs: -------------------------------------------------------------------------------- 1 | import System.IO 2 | 3 | fuel :: Int -> Int 4 | fuel mass = (div mass 3) - 2 5 | 6 | main = do 7 | contents <- readFile "input.txt" 8 | let mass = map read (lines contents) 9 | print $ sum (map fuel mass) 10 | -------------------------------------------------------------------------------- /day01/day01_2.hs: -------------------------------------------------------------------------------- 1 | import System.IO 2 | 3 | fuel :: Int -> Int 4 | 5 | fuel mass | mass > 0 = 6 | let f = max ((div mass 3) - 2) 0 7 | in f + (fuel f) 8 | 9 | fuel mass | otherwise = 0 10 | 11 | main = do 12 | contents <- readFile "input.txt" 13 | let mass = map read (lines contents) 14 | print $ sum (map fuel mass) 15 | -------------------------------------------------------------------------------- /day02/input.txt: -------------------------------------------------------------------------------- 1 | 1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,10,1,19,1,19,5,23,1,23,9,27,2,27,6,31,1,31,6,35,2,35,9,39,1,6,39,43,2,10,43,47,1,47,9,51,1,51,6,55,1,55,6,59,2,59,10,63,1,6,63,67,2,6,67,71,1,71,5,75,2,13,75,79,1,10,79,83,1,5,83,87,2,87,10,91,1,5,91,95,2,95,6,99,1,99,6,103,2,103,6,107,2,107,9,111,1,111,5,115,1,115,6,119,2,6,119,123,1,5,123,127,1,127,13,131,1,2,131,135,1,135,10,0,99,2,14,0,0 -------------------------------------------------------------------------------- /day07/day02.txt: -------------------------------------------------------------------------------- 1 | 1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,1,9,19,1,19,5,23,1,13,23,27,1,27,6,31,2,31,6,35,2,6,35,39,1,39,5,43,1,13,43,47,1,6,47,51,2,13,51,55,1,10,55,59,1,59,5,63,1,10,63,67,1,67,5,71,1,71,10,75,1,9,75,79,2,13,79,83,1,9,83,87,2,87,13,91,1,10,91,95,1,95,9,99,1,13,99,103,2,103,13,107,1,107,10,111,2,10,111,115,1,115,9,119,2,119,6,123,1,5,123,127,1,5,127,131,1,10,131,135,1,135,6,139,1,10,139,143,1,143,6,147,2,147,13,151,1,5,151,155,1,155,5,159,1,159,2,163,1,163,9,0,99,2,14,0,0 2 | -------------------------------------------------------------------------------- /stack.yaml.lock: -------------------------------------------------------------------------------- 1 | # This file was autogenerated by Stack. 2 | # You should not edit this file by hand. 3 | # For more information, please see the documentation at: 4 | # https://docs.haskellstack.org/en/stable/lock_files 5 | 6 | packages: [] 7 | snapshots: 8 | - completed: 9 | size: 524799 10 | url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/14/17.yaml 11 | sha256: 1d72b33c0fc048e23f4f18fd76a6ad79dd1d8a3c054644098a71a09855e40c7c 12 | original: lts-14.17 13 | -------------------------------------------------------------------------------- /day06/stack.yaml.lock: -------------------------------------------------------------------------------- 1 | # This file was autogenerated by Stack. 2 | # You should not edit this file by hand. 3 | # For more information, please see the documentation at: 4 | # https://docs.haskellstack.org/en/stable/lock_files 5 | 6 | packages: [] 7 | snapshots: 8 | - completed: 9 | size: 524799 10 | url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/14/17.yaml 11 | sha256: 1d72b33c0fc048e23f4f18fd76a6ad79dd1d8a3c054644098a71a09855e40c7c 12 | original: lts-14.17 13 | -------------------------------------------------------------------------------- /day07_old/stack.yaml.lock: -------------------------------------------------------------------------------- 1 | # This file was autogenerated by Stack. 2 | # You should not edit this file by hand. 3 | # For more information, please see the documentation at: 4 | # https://docs.haskellstack.org/en/stable/lock_files 5 | 6 | packages: [] 7 | snapshots: 8 | - completed: 9 | size: 524799 10 | url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/14/17.yaml 11 | sha256: 1d72b33c0fc048e23f4f18fd76a6ad79dd1d8a3c054644098a71a09855e40c7c 12 | original: lts-14.17 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | * 3 | !/**/ 4 | !*.* 5 | 6 | # Created by https://www.gitignore.io/api/haskell 7 | # Edit at https://www.gitignore.io/?templates=haskell 8 | 9 | ### Haskell ### 10 | dist 11 | dist-* 12 | cabal-dev 13 | *.o 14 | *.hi 15 | *.chi 16 | *.chs.h 17 | *.dyn_o 18 | *.dyn_hi 19 | .hpc 20 | .hsenv 21 | .cabal-sandbox/ 22 | cabal.sandbox.config 23 | *.prof 24 | *.aux 25 | *.hp 26 | *.eventlog 27 | .stack-work/ 28 | cabal.project.local 29 | cabal.project.local~ 30 | .HTF/ 31 | .ghc.environment.* 32 | 33 | # End of https://www.gitignore.io/api/haskell 34 | -------------------------------------------------------------------------------- /day07/day07.cabal: -------------------------------------------------------------------------------- 1 | name: day07 2 | version: 0.1.0.0 3 | -- synopsis: 4 | -- description: 5 | homepage: https://github.com/githubuser/day07#readme 6 | license: BSD3 7 | license-file: LICENSE 8 | author: Author name here 9 | maintainer: example@example.com 10 | copyright: 2019 Author name here 11 | category: Web 12 | build-type: Simple 13 | cabal-version: >=1.10 14 | extra-source-files: README.md 15 | 16 | executable day07 17 | hs-source-dirs: src 18 | main-is: day07.hs 19 | default-language: Haskell2010 20 | build-depends: base >= 4.7 && < 5 21 | , split 22 | , containers 23 | , mtl 24 | -------------------------------------------------------------------------------- /day04/day04.hs: -------------------------------------------------------------------------------- 1 | import Control.Exception 2 | import Data.List 3 | import Data.Maybe 4 | 5 | match :: Int -> Maybe Int 6 | match n = 7 | if any (uncurry (==)) pairs && all (uncurry (<=)) pairs 8 | then Just n 9 | else Nothing 10 | where 11 | s = show n 12 | pairs = zip s (tail s) 13 | 14 | match2 n = 15 | if all (uncurry (<=)) pairs && elem 2 (map length $ group s) 16 | then Just n 17 | else Nothing 18 | where 19 | s = show n 20 | pairs = zip s (tail s) 21 | 22 | main = do 23 | assert (match 111111 == Just 111111) return () 24 | assert (isNothing $ match 223450) return () 25 | assert (isNothing $ match 665432) return () 26 | assert (isNothing $ match 123789) return () 27 | let range = [130254 .. 678275] 28 | print $ length $ mapMaybe match range 29 | assert (isNothing $ match2 111111) return () 30 | assert (isNothing $ match2 123444) return () 31 | assert (match2 111122 == Just 111122) return () 32 | print $ length $ mapMaybe match2 range 33 | -------------------------------------------------------------------------------- /day07/input.txt: -------------------------------------------------------------------------------- 1 | 3,8,1001,8,10,8,105,1,0,0,21,38,59,84,93,110,191,272,353,434,99999,3,9,101,5,9,9,1002,9,5,9,101,5,9,9,4,9,99,3,9,1001,9,3,9,1002,9,2,9,101,4,9,9,1002,9,4,9,4,9,99,3,9,102,5,9,9,1001,9,4,9,1002,9,2,9,1001,9,5,9,102,4,9,9,4,9,99,3,9,1002,9,2,9,4,9,99,3,9,1002,9,5,9,101,4,9,9,102,2,9,9,4,9,99,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1001,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,102,2,9,9,4,9,99,3,9,102,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,1001,9,1,9,4,9,3,9,1001,9,1,9,4,9,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,1001,9,2,9,4,9,99,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1001,9,1,9,4,9,3,9,1001,9,1,9,4,9,3,9,1002,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,101,1,9,9,4,9,99,3,9,1001,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,102,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,99,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1001,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,1001,9,2,9,4,9,3,9,101,1,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,101,1,9,9,4,9,3,9,1001,9,1,9,4,9,99 -------------------------------------------------------------------------------- /day07_old/input.txt: -------------------------------------------------------------------------------- 1 | 3,8,1001,8,10,8,105,1,0,0,21,38,59,84,93,110,191,272,353,434,99999,3,9,101,5,9,9,1002,9,5,9,101,5,9,9,4,9,99,3,9,1001,9,3,9,1002,9,2,9,101,4,9,9,1002,9,4,9,4,9,99,3,9,102,5,9,9,1001,9,4,9,1002,9,2,9,1001,9,5,9,102,4,9,9,4,9,99,3,9,1002,9,2,9,4,9,99,3,9,1002,9,5,9,101,4,9,9,102,2,9,9,4,9,99,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1001,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,102,2,9,9,4,9,99,3,9,102,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,1001,9,1,9,4,9,3,9,1001,9,1,9,4,9,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,1001,9,2,9,4,9,99,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1001,9,1,9,4,9,3,9,1001,9,1,9,4,9,3,9,1002,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,101,1,9,9,4,9,99,3,9,1001,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,102,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,99,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1001,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,1001,9,2,9,4,9,3,9,101,1,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,101,1,9,9,4,9,3,9,1001,9,1,9,4,9,99 -------------------------------------------------------------------------------- /day01/input.txt: -------------------------------------------------------------------------------- 1 | 109044 2 | 60212 3 | 64742 4 | 142138 5 | 136568 6 | 75419 7 | 53333 8 | 92829 9 | 101974 10 | 129727 11 | 146189 12 | 59012 13 | 128230 14 | 82014 15 | 95644 16 | 104718 17 | 56678 18 | 140456 19 | 109579 20 | 76097 21 | 120110 22 | 129504 23 | 64430 24 | 107567 25 | 125459 26 | 149627 27 | 55625 28 | 113110 29 | 65923 30 | 96290 31 | 104284 32 | 144037 33 | 95560 34 | 84681 35 | 89824 36 | 122408 37 | 126032 38 | 54599 39 | 104811 40 | 127899 41 | 100164 42 | 69858 43 | 74350 44 | 111938 45 | 73606 46 | 144204 47 | 61446 48 | 87402 49 | 89622 50 | 113447 51 | 100960 52 | 134911 53 | 66807 54 | 75058 55 | 97648 56 | 131844 57 | 71501 58 | 52357 59 | 62832 60 | 140644 61 | 110284 62 | 132475 63 | 94625 64 | 146008 65 | 130087 66 | 124206 67 | 68642 68 | 52188 69 | 139127 70 | 83640 71 | 60401 72 | 102333 73 | 78650 74 | 138770 75 | 73078 76 | 60696 77 | 58898 78 | 87419 79 | 71292 80 | 69120 81 | 81081 82 | 50448 83 | 94644 84 | 103919 85 | 66507 86 | 90795 87 | 135753 88 | 84528 89 | 103454 90 | 91278 91 | 53749 92 | 126764 93 | 58397 94 | 54734 95 | 63086 96 | 60787 97 | 120579 98 | 110097 99 | 91947 100 | 105584 -------------------------------------------------------------------------------- /day06/day06.hs: -------------------------------------------------------------------------------- 1 | import Data.List.Split 2 | import Data.Map (Map) 3 | import qualified Data.Map.Strict as Map 4 | import qualified Data.Set as Set 5 | import Data.Tree 6 | 7 | parse :: [String] -> Map String String 8 | parse xs = Map.fromList $ map (tup . splitOn ")") xs 9 | where 10 | tup (a:b:_) = (b, a) 11 | 12 | findCOM :: Maybe String -> Map String String -> Maybe [String] -> Maybe [String] 13 | findCOM key mapping path = 14 | case key of 15 | Just "COM" -> path 16 | Just key -> findCOM (Map.lookup key mapping) mapping (fmap (key :) path) 17 | Nothing -> Nothing 18 | 19 | count :: Map String String -> Maybe Int 20 | count mapping = do 21 | counts <- 22 | mapM 23 | (\s -> length <$> findCOM (Just s) mapping (Just [])) 24 | (Map.keys mapping) 25 | Just $ sum counts 26 | 27 | xor :: Ord a => Set.Set a -> Set.Set a -> Set.Set a 28 | xor a b = Set.union a b `Set.difference` Set.intersection a b 29 | 30 | findPath :: String -> String -> Map String String -> Maybe Int 31 | findPath a b mapping = do 32 | pathA <- Set.fromList <$> findCOM (Just a) mapping (Just []) 33 | pathB <- Set.fromList <$> findCOM (Just b) mapping (Just []) 34 | Just $ flip (-) 2 . Set.size $ xor pathA pathB 35 | 36 | main = do 37 | content <- readFile "input.txt" 38 | let mapping = parse (lines content) 39 | print $ count mapping 40 | print $ findPath "YOU" "SAN" mapping 41 | -------------------------------------------------------------------------------- /day02/day02.hs: -------------------------------------------------------------------------------- 1 | import System.IO 2 | import Data.IntMap.Strict (IntMap, (!)) 3 | import qualified Data.IntMap.Lazy as M 4 | import qualified Data.IntMap.Lazy as IntMap 5 | import Control.Exception 6 | import Debug.Trace 7 | 8 | import Control.Monad ((>=>)) 9 | import Data.List.Split 10 | 11 | step :: IntMap Int -> Int -> Maybe (IntMap Int) 12 | step prog counter = do 13 | let getReg = flip M.lookup prog 14 | let loadWord = getReg >=> getReg 15 | inst <- getReg counter 16 | case inst of 17 | 99 -> Just prog 18 | _ -> do 19 | a <- loadWord (counter + 1) 20 | b <- loadWord (counter + 2) 21 | dest <- getReg (counter + 3) 22 | let exec op = step (IntMap.insert dest (a `op` b) (prog)) (counter + 4) 23 | case inst of 24 | 1 -> exec (+) 25 | 2 -> exec (*) 26 | _ -> Nothing 27 | 28 | run :: IntMap Int -> Int -> Int -> Maybe Int 29 | run prog noun verb = do 30 | prog <- step (IntMap.insert 1 noun $ IntMap.insert 2 verb prog) 0 31 | M.lookup 0 prog 32 | 33 | part1 prog = case run prog 12 2 of 34 | Just res -> res 35 | Nothing -> error "No result" 36 | 37 | gridsearch :: IntMap Int -> Int -> [(Int, Int)] -> (Int, Int) 38 | gridsearch prog value ((noun, verb):space) 39 | | res == Just value = (noun, verb) 40 | | otherwise = gridsearch prog value space 41 | where res = run prog noun verb 42 | 43 | constructRegister :: [Int] -> IntMap Int 44 | constructRegister = IntMap.fromList . zip [0..] 45 | 46 | part2 prog = let range = [0..99] 47 | space = [(x, y) | x <- range, y <- range] 48 | (noun, verb) = gridsearch prog 19690720 space 49 | in 100 * noun + verb 50 | 51 | 52 | traceThis a = trace (show a) a 53 | 54 | verify input output = 55 | assert (step (constructRegister input) 0 == Just (constructRegister output)) return () 56 | 57 | main = do 58 | contents <- readFile "input.txt" 59 | let prog = constructRegister $ (map read (splitOn "," contents) :: [Int]) 60 | 61 | verify [1,9,10,3,2,3,11,0,99,30,40,50] [3500,9,10,70,2,3,11,0,99,30,40,50] 62 | verify [1,0,0,0,99] [2,0,0,0,99] 63 | verify [2,3,0,3,99] [2,3,0,6,99] 64 | verify [2,4,4,5,99,0] [2,4,4,5,99,9801] 65 | verify [1,1,1,4,99,5,6,0,99] [30,1,1,4,2,5,6,0,99] 66 | 67 | print $ "Part 1: " ++ (show $ part1 prog) 68 | print $ "Part 2: " ++ (show $ part2 prog) 69 | -------------------------------------------------------------------------------- /stack.yaml: -------------------------------------------------------------------------------- 1 | # This file was automatically generated by 'stack init' 2 | # 3 | # Some commonly used options have been documented as comments in this file. 4 | # For advanced use and comprehensive documentation of the format, please see: 5 | # https://docs.haskellstack.org/en/stable/yaml_configuration/ 6 | 7 | # Resolver to choose a 'specific' stackage snapshot or a compiler version. 8 | # A snapshot resolver dictates the compiler version and the set of packages 9 | # to be used for project dependencies. For example: 10 | # 11 | # resolver: lts-3.5 12 | # resolver: nightly-2015-09-21 13 | # resolver: ghc-7.10.2 14 | # 15 | # The location of a snapshot can be provided as a file or url. Stack assumes 16 | # a snapshot provided as a file might change, whereas a url resource does not. 17 | # 18 | # resolver: ./custom-snapshot.yaml 19 | # resolver: https://example.com/snapshots/2018-01-01.yaml 20 | resolver: lts-14.17 21 | 22 | # User packages to be built. 23 | # Various formats can be used as shown in the example below. 24 | # 25 | # packages: 26 | # - some-directory 27 | # - https://example.com/foo/bar/baz-0.0.2.tar.gz 28 | # subdirs: 29 | # - auto-update 30 | # - wai 31 | packages: [] 32 | # Dependency packages to be pulled from upstream that are not in the resolver. 33 | # These entries can reference officially published versions as well as 34 | # forks / in-progress versions pinned to a git hash. For example: 35 | # 36 | # extra-deps: 37 | # - acme-missiles-0.3 38 | # - git: https://github.com/commercialhaskell/stack.git 39 | # commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a 40 | # 41 | # extra-deps: [] 42 | 43 | # Override default flag values for local packages and extra-deps 44 | # flags: {} 45 | 46 | # Extra package databases containing global packages 47 | # extra-package-dbs: [] 48 | 49 | # Control whether we use the GHC we find on the path 50 | # system-ghc: true 51 | # 52 | # Require a specific version of stack, using version ranges 53 | # require-stack-version: -any # Default 54 | # require-stack-version: ">=2.1" 55 | # 56 | # Override the architecture used by stack, especially useful on Windows 57 | # arch: i386 58 | # arch: x86_64 59 | # 60 | # Extra directories used by stack for building 61 | extra-include-dirs: [.] 62 | # extra-lib-dirs: [/path/to/dir] 63 | # 64 | # Allow a newer minor version of GHC than the snapshot specifies 65 | # compiler-check: newer-minor 66 | -------------------------------------------------------------------------------- /day06/stack.yaml: -------------------------------------------------------------------------------- 1 | # This file was automatically generated by 'stack init' 2 | # 3 | # Some commonly used options have been documented as comments in this file. 4 | # For advanced use and comprehensive documentation of the format, please see: 5 | # https://docs.haskellstack.org/en/stable/yaml_configuration/ 6 | 7 | # Resolver to choose a 'specific' stackage snapshot or a compiler version. 8 | # A snapshot resolver dictates the compiler version and the set of packages 9 | # to be used for project dependencies. For example: 10 | # 11 | # resolver: lts-3.5 12 | # resolver: nightly-2015-09-21 13 | # resolver: ghc-7.10.2 14 | # 15 | # The location of a snapshot can be provided as a file or url. Stack assumes 16 | # a snapshot provided as a file might change, whereas a url resource does not. 17 | # 18 | # resolver: ./custom-snapshot.yaml 19 | # resolver: https://example.com/snapshots/2018-01-01.yaml 20 | resolver: lts-14.17 21 | 22 | # User packages to be built. 23 | # Various formats can be used as shown in the example below. 24 | # 25 | # packages: 26 | # - some-directory 27 | # - https://example.com/foo/bar/baz-0.0.2.tar.gz 28 | # subdirs: 29 | # - auto-update 30 | # - wai 31 | packages: [] 32 | # Dependency packages to be pulled from upstream that are not in the resolver. 33 | # These entries can reference officially published versions as well as 34 | # forks / in-progress versions pinned to a git hash. For example: 35 | # 36 | # extra-deps: 37 | # - acme-missiles-0.3 38 | # - git: https://github.com/commercialhaskell/stack.git 39 | # commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a 40 | # 41 | # extra-deps: [] 42 | 43 | # Override default flag values for local packages and extra-deps 44 | # flags: {} 45 | 46 | # Extra package databases containing global packages 47 | # extra-package-dbs: [] 48 | 49 | # Control whether we use the GHC we find on the path 50 | # system-ghc: true 51 | # 52 | # Require a specific version of stack, using version ranges 53 | # require-stack-version: -any # Default 54 | # require-stack-version: ">=2.1" 55 | # 56 | # Override the architecture used by stack, especially useful on Windows 57 | # arch: i386 58 | # arch: x86_64 59 | # 60 | # Extra directories used by stack for building 61 | extra-include-dirs: [.] 62 | # extra-lib-dirs: [/path/to/dir] 63 | # 64 | # Allow a newer minor version of GHC than the snapshot specifies 65 | # compiler-check: newer-minor 66 | -------------------------------------------------------------------------------- /day07_old/stack.yaml: -------------------------------------------------------------------------------- 1 | # This file was automatically generated by 'stack init' 2 | # 3 | # Some commonly used options have been documented as comments in this file. 4 | # For advanced use and comprehensive documentation of the format, please see: 5 | # https://docs.haskellstack.org/en/stable/yaml_configuration/ 6 | 7 | # Resolver to choose a 'specific' stackage snapshot or a compiler version. 8 | # A snapshot resolver dictates the compiler version and the set of packages 9 | # to be used for project dependencies. For example: 10 | # 11 | # resolver: lts-3.5 12 | # resolver: nightly-2015-09-21 13 | # resolver: ghc-7.10.2 14 | # 15 | # The location of a snapshot can be provided as a file or url. Stack assumes 16 | # a snapshot provided as a file might change, whereas a url resource does not. 17 | # 18 | # resolver: ./custom-snapshot.yaml 19 | # resolver: https://example.com/snapshots/2018-01-01.yaml 20 | resolver: lts-14.17 21 | 22 | # User packages to be built. 23 | # Various formats can be used as shown in the example below. 24 | # 25 | # packages: 26 | # - some-directory 27 | # - https://example.com/foo/bar/baz-0.0.2.tar.gz 28 | # subdirs: 29 | # - auto-update 30 | # - wai 31 | packages: [] 32 | # Dependency packages to be pulled from upstream that are not in the resolver. 33 | # These entries can reference officially published versions as well as 34 | # forks / in-progress versions pinned to a git hash. For example: 35 | # 36 | # extra-deps: 37 | # - acme-missiles-0.3 38 | # - git: https://github.com/commercialhaskell/stack.git 39 | # commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a 40 | # 41 | # extra-deps: [] 42 | 43 | # Override default flag values for local packages and extra-deps 44 | # flags: {} 45 | 46 | # Extra package databases containing global packages 47 | # extra-package-dbs: [] 48 | 49 | # Control whether we use the GHC we find on the path 50 | # system-ghc: true 51 | # 52 | # Require a specific version of stack, using version ranges 53 | # require-stack-version: -any # Default 54 | # require-stack-version: ">=2.1" 55 | # 56 | # Override the architecture used by stack, especially useful on Windows 57 | # arch: i386 58 | # arch: x86_64 59 | # 60 | # Extra directories used by stack for building 61 | extra-include-dirs: [.] 62 | # extra-lib-dirs: [/path/to/dir] 63 | # 64 | # Allow a newer minor version of GHC than the snapshot specifies 65 | # compiler-check: newer-minor 66 | -------------------------------------------------------------------------------- /day07/stack.yaml: -------------------------------------------------------------------------------- 1 | # This file was automatically generated by 'stack init' 2 | # 3 | # Some commonly used options have been documented as comments in this file. 4 | # For advanced use and comprehensive documentation of the format, please see: 5 | # https://docs.haskellstack.org/en/stable/yaml_configuration/ 6 | 7 | # Resolver to choose a 'specific' stackage snapshot or a compiler version. 8 | # A snapshot resolver dictates the compiler version and the set of packages 9 | # to be used for project dependencies. For example: 10 | # 11 | # resolver: lts-3.5 12 | # resolver: nightly-2015-09-21 13 | # resolver: ghc-7.10.2 14 | # 15 | # The location of a snapshot can be provided as a file or url. Stack assumes 16 | # a snapshot provided as a file might change, whereas a url resource does not. 17 | # 18 | # resolver: ./custom-snapshot.yaml 19 | # resolver: https://example.com/snapshots/2018-01-01.yaml 20 | resolver: lts-14.17 21 | 22 | # User packages to be built. 23 | # Various formats can be used as shown in the example below. 24 | # 25 | # packages: 26 | # - some-directory 27 | # - https://example.com/foo/bar/baz-0.0.2.tar.gz 28 | # - location: 29 | # git: https://github.com/commercialhaskell/stack.git 30 | # commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a 31 | # - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a 32 | # subdirs: 33 | # - auto-update 34 | # - wai 35 | packages: 36 | - . 37 | # Dependency packages to be pulled from upstream that are not in the resolver 38 | # using the same syntax as the packages field. 39 | # (e.g., acme-missiles-0.3) 40 | # extra-deps: [] 41 | 42 | # Override default flag values for local packages and extra-deps 43 | # flags: {} 44 | 45 | # Extra package databases containing global packages 46 | # extra-package-dbs: [] 47 | 48 | # Control whether we use the GHC we find on the path 49 | # system-ghc: true 50 | # 51 | # Require a specific version of stack, using version ranges 52 | # require-stack-version: -any # Default 53 | # require-stack-version: ">=1.9" 54 | # 55 | # Override the architecture used by stack, especially useful on Windows 56 | # arch: i386 57 | # arch: x86_64 58 | # 59 | # Extra directories used by stack for building 60 | # extra-include-dirs: [/path/to/dir] 61 | # extra-lib-dirs: [/path/to/dir] 62 | # 63 | # Allow a newer minor version of GHC than the snapshot specifies 64 | # compiler-check: newer-minor 65 | -------------------------------------------------------------------------------- /day05/input.txt: -------------------------------------------------------------------------------- 1 | 3,225,1,225,6,6,1100,1,238,225,104,0,1101,32,43,225,101,68,192,224,1001,224,-160,224,4,224,102,8,223,223,1001,224,2,224,1,223,224,223,1001,118,77,224,1001,224,-87,224,4,224,102,8,223,223,1001,224,6,224,1,223,224,223,1102,5,19,225,1102,74,50,224,101,-3700,224,224,4,224,1002,223,8,223,1001,224,1,224,1,223,224,223,1102,89,18,225,1002,14,72,224,1001,224,-3096,224,4,224,102,8,223,223,101,5,224,224,1,223,224,223,1101,34,53,225,1102,54,10,225,1,113,61,224,101,-39,224,224,4,224,102,8,223,223,101,2,224,224,1,223,224,223,1101,31,61,224,101,-92,224,224,4,224,102,8,223,223,1001,224,4,224,1,223,224,223,1102,75,18,225,102,48,87,224,101,-4272,224,224,4,224,102,8,223,223,1001,224,7,224,1,224,223,223,1101,23,92,225,2,165,218,224,101,-3675,224,224,4,224,1002,223,8,223,101,1,224,224,1,223,224,223,1102,8,49,225,4,223,99,0,0,0,677,0,0,0,0,0,0,0,0,0,0,0,1105,0,99999,1105,227,247,1105,1,99999,1005,227,99999,1005,0,256,1105,1,99999,1106,227,99999,1106,0,265,1105,1,99999,1006,0,99999,1006,227,274,1105,1,99999,1105,1,280,1105,1,99999,1,225,225,225,1101,294,0,0,105,1,0,1105,1,99999,1106,0,300,1105,1,99999,1,225,225,225,1101,314,0,0,106,0,0,1105,1,99999,1107,226,226,224,1002,223,2,223,1005,224,329,1001,223,1,223,1007,677,226,224,1002,223,2,223,1006,224,344,1001,223,1,223,108,677,226,224,102,2,223,223,1006,224,359,1001,223,1,223,7,226,226,224,1002,223,2,223,1005,224,374,101,1,223,223,107,677,677,224,1002,223,2,223,1006,224,389,1001,223,1,223,1007,677,677,224,1002,223,2,223,1006,224,404,1001,223,1,223,1107,677,226,224,1002,223,2,223,1005,224,419,1001,223,1,223,108,226,226,224,102,2,223,223,1006,224,434,1001,223,1,223,1108,226,677,224,1002,223,2,223,1006,224,449,1001,223,1,223,1108,677,226,224,102,2,223,223,1005,224,464,1001,223,1,223,107,226,226,224,102,2,223,223,1006,224,479,1001,223,1,223,1008,226,226,224,102,2,223,223,1005,224,494,101,1,223,223,7,677,226,224,1002,223,2,223,1005,224,509,101,1,223,223,8,226,677,224,1002,223,2,223,1006,224,524,1001,223,1,223,1007,226,226,224,1002,223,2,223,1006,224,539,101,1,223,223,1008,677,677,224,1002,223,2,223,1006,224,554,101,1,223,223,1108,677,677,224,102,2,223,223,1006,224,569,101,1,223,223,1107,226,677,224,102,2,223,223,1005,224,584,1001,223,1,223,8,677,226,224,1002,223,2,223,1006,224,599,101,1,223,223,1008,677,226,224,102,2,223,223,1006,224,614,1001,223,1,223,7,226,677,224,1002,223,2,223,1005,224,629,101,1,223,223,107,226,677,224,102,2,223,223,1005,224,644,101,1,223,223,8,677,677,224,102,2,223,223,1005,224,659,1001,223,1,223,108,677,677,224,1002,223,2,223,1005,224,674,101,1,223,223,4,223,99,226 -------------------------------------------------------------------------------- /day07/day05.txt: -------------------------------------------------------------------------------- 1 | 3,225,1,225,6,6,1100,1,238,225,104,0,1,191,196,224,1001,224,-85,224,4,224,1002,223,8,223,1001,224,4,224,1,223,224,223,1101,45,50,225,1102,61,82,225,101,44,39,224,101,-105,224,224,4,224,102,8,223,223,101,5,224,224,1,224,223,223,102,14,187,224,101,-784,224,224,4,224,102,8,223,223,101,7,224,224,1,224,223,223,1001,184,31,224,1001,224,-118,224,4,224,102,8,223,223,1001,224,2,224,1,223,224,223,1102,91,18,225,2,35,110,224,101,-810,224,224,4,224,102,8,223,223,101,3,224,224,1,223,224,223,1101,76,71,224,1001,224,-147,224,4,224,102,8,223,223,101,2,224,224,1,224,223,223,1101,7,16,225,1102,71,76,224,101,-5396,224,224,4,224,1002,223,8,223,101,5,224,224,1,224,223,223,1101,72,87,225,1101,56,77,225,1102,70,31,225,1102,29,15,225,1002,158,14,224,1001,224,-224,224,4,224,102,8,223,223,101,1,224,224,1,223,224,223,4,223,99,0,0,0,677,0,0,0,0,0,0,0,0,0,0,0,1105,0,99999,1105,227,247,1105,1,99999,1005,227,99999,1005,0,256,1105,1,99999,1106,227,99999,1106,0,265,1105,1,99999,1006,0,99999,1006,227,274,1105,1,99999,1105,1,280,1105,1,99999,1,225,225,225,1101,294,0,0,105,1,0,1105,1,99999,1106,0,300,1105,1,99999,1,225,225,225,1101,314,0,0,106,0,0,1105,1,99999,1007,226,226,224,1002,223,2,223,1006,224,329,1001,223,1,223,8,226,677,224,1002,223,2,223,1005,224,344,1001,223,1,223,107,226,677,224,1002,223,2,223,1006,224,359,1001,223,1,223,8,677,677,224,1002,223,2,223,1005,224,374,1001,223,1,223,1108,226,226,224,1002,223,2,223,1005,224,389,1001,223,1,223,7,677,226,224,1002,223,2,223,1005,224,404,101,1,223,223,7,226,226,224,102,2,223,223,1006,224,419,1001,223,1,223,1108,226,677,224,102,2,223,223,1005,224,434,1001,223,1,223,1107,226,226,224,1002,223,2,223,1006,224,449,1001,223,1,223,1007,677,677,224,102,2,223,223,1006,224,464,1001,223,1,223,107,226,226,224,1002,223,2,223,1005,224,479,101,1,223,223,1107,677,226,224,1002,223,2,223,1005,224,494,1001,223,1,223,1008,677,677,224,102,2,223,223,1005,224,509,101,1,223,223,107,677,677,224,102,2,223,223,1005,224,524,1001,223,1,223,1108,677,226,224,1002,223,2,223,1005,224,539,1001,223,1,223,7,226,677,224,102,2,223,223,1006,224,554,1001,223,1,223,8,677,226,224,1002,223,2,223,1006,224,569,101,1,223,223,108,226,226,224,1002,223,2,223,1006,224,584,1001,223,1,223,1107,226,677,224,1002,223,2,223,1006,224,599,101,1,223,223,1008,226,226,224,102,2,223,223,1005,224,614,1001,223,1,223,1007,226,677,224,1002,223,2,223,1006,224,629,1001,223,1,223,108,677,226,224,102,2,223,223,1005,224,644,101,1,223,223,1008,226,677,224,1002,223,2,223,1005,224,659,101,1,223,223,108,677,677,224,1002,223,2,223,1006,224,674,1001,223,1,223,4,223,99,226 2 | -------------------------------------------------------------------------------- /day03/input.txt: -------------------------------------------------------------------------------- 1 | R1003,U756,L776,U308,R718,D577,R902,D776,R760,U638,R289,D70,L885,U161,R807,D842,R175,D955,R643,U380,R329,U573,L944,D2,L807,D886,L549,U592,R152,D884,L761,D915,L726,D677,L417,D651,L108,D377,L699,D938,R555,D222,L689,D196,L454,U309,L470,D234,R198,U689,L996,U117,R208,D310,R572,D562,L207,U244,L769,U186,R153,D756,R97,D625,R686,U244,R348,U586,L385,D466,R483,U718,L892,D39,R692,U756,L724,U148,R70,U224,L837,D370,L309,U235,R382,D579,R404,D146,R6,U584,L840,D863,R942,U646,R146,D618,L12,U210,R126,U163,R931,D661,L710,D883,L686,D688,L148,D19,R703,U530,R889,U186,R779,D503,R417,U272,R541,U21,L562,D10,L349,U998,R69,D65,R560,D585,L949,D372,L110,D865,R212,U56,L936,U957,L88,U612,R927,U642,R416,U348,L541,D416,L808,D759,R449,D6,L517,D4,R494,D143,L536,U341,R394,U179,L22,D680,L138,U249,L285,U879,L717,U756,L313,U222,R823,D208,L134,U984,R282,U635,R207,D63,L416,U511,L179,D582,L651,U932,R646,U378,R263,U138,L920,U523,L859,D556,L277,D518,R489,U561,L457,D297,R72,U920,L583,U23,L395,D844,R776,D552,L55,D500,R111,U409,R685,D427,R275,U739,R181,U333,L215,U808,R341,D537,R336,U230,R247,U748,R846,U404,R850,D493,R891,U176,L744,U585,L987,D849,R271,D848,L555,U801,R316,U753,L390,U97,L128,U45,R706,U35,L928,U913,R537,D512,R152,D410,R76,D209,R183,U941,R289,U632,L923,D190,R488,D934,R442,D303,R178,D250,R204,U247,R707,U77,R428,D701,R386,U110,R641,U925,R703,D387,L946,U415,R461,D123,L214,U236,L959,U517,R957,D524,R812,D668,R369,U340,L606,D503,R755,U390,R142,D921,L976,D36,L965,D450,L722,D224,L303,U705,L584 2 | L993,U810,L931,D139,R114,D77,L75,U715,R540,D994,L866,U461,R340,D179,R314,D423,R629,D8,L692,U446,L88,D132,L128,U934,L465,D58,L696,D883,L955,D565,R424,U286,R403,U57,L627,D930,R887,D941,L306,D951,R918,U587,R939,U821,L65,D18,L987,D707,L360,D54,L932,U366,R625,U609,R173,D637,R661,U888,L68,U962,R270,U369,R780,U845,L813,U481,R66,D182,R420,U605,R880,D276,L6,D529,R883,U189,R380,D472,R30,U35,L510,D844,L146,U875,R152,U545,R274,U920,R432,U814,R583,D559,L820,U135,L353,U975,L103,U615,R401,U692,L676,D781,R551,D985,L317,U836,R115,D216,L967,U286,R681,U144,L354,U678,L893,D487,R664,D185,R787,D909,L582,D283,L519,D893,L56,U768,L345,D992,L248,U439,R573,D98,L390,D43,L470,D435,R176,U468,R688,U388,L377,U800,R187,U641,L268,U857,L716,D179,R212,U196,L342,U731,R261,D92,R183,D623,L589,D215,L966,U878,L784,U740,R823,D99,L167,D992,R414,U22,L27,U390,R286,D744,L360,U554,L756,U715,R939,D806,R279,U292,L960,U633,L428,U949,R90,D321,R749,U395,L392,U348,L33,D757,R289,D367,L562,D668,L79,D193,L991,D705,L562,U25,R146,D34,R325,U203,R403,D714,R607,U72,L444,D76,R267,U924,R289,U962,L159,U726,L57,D540,R299,U343,R936,U90,L311,U243,L415,D426,L936,D570,L539,D731,R367,D374,L56,D251,L265,U65,L14,D882,L956,U88,R688,D34,R866,U777,R342,D270,L344,D953,L438,D855,L587,U320,L953,D945,L473,U559,L487,D602,R255,U871,L854,U45,R705,D247,R955,U885,R657,D664,L360,D764,L549,D676,R85,U189,L951,D922,R511,D429,R37,U11,R821,U984,R825,U874,R753,D524,L537,U618,L919,D597,L364,D231,L258,U818,R406,D208,R214,U530,R261 -------------------------------------------------------------------------------- /day03/day03.hs: -------------------------------------------------------------------------------- 1 | import Control.Exception 2 | import Data.List.Split 3 | import Data.Maybe 4 | import Debug.Trace 5 | import System.IO 6 | 7 | data Direction 8 | = North 9 | | East 10 | | South 11 | | West 12 | deriving (Show) 13 | 14 | data Path = 15 | Path Direction Int 16 | deriving (Show) 17 | 18 | data Point = 19 | Point Int Int 20 | deriving (Show) 21 | 22 | data Line 23 | = HLine Int Int Int 24 | | VLine Int Int Int 25 | deriving (Show) 26 | 27 | traceThis a = trace (show a) a 28 | 29 | parsePath :: String -> Maybe Path 30 | parsePath (d:len) = do 31 | dir <- 32 | case d of 33 | 'U' -> Just North 34 | 'R' -> Just East 35 | 'D' -> Just South 36 | 'L' -> Just West 37 | _ -> Nothing 38 | Just (Path dir (read len :: Int)) 39 | 40 | parseWire :: [String] -> Maybe [Path] 41 | parseWire = mapM parsePath 42 | 43 | path2line :: Point -> Path -> (Line, Point, Int) 44 | path2line (Point x y) path = 45 | case path of 46 | (Path North l) -> (VLine x y (y + l), Point x (y + l), l) 47 | (Path East l) -> (HLine x (x + l) y, Point (x + l) y, l) 48 | (Path South l) -> (VLine x y (y - l), Point x (y - l), l) 49 | (Path West l) -> (HLine x (x - l) y, Point (x - l) y, l) 50 | 51 | getLines :: Maybe [Path] -> [(Line, Int)] 52 | getLines (Just paths) = fst $ foldl reduce ([], (Point 0 0, 0)) paths 53 | where 54 | reduce (lst, (point, len)) path = 55 | ((line, len) : lst, (newPoint, len + newLen)) 56 | where 57 | (line, newPoint, newLen) = path2line point path 58 | getLines _ = [] 59 | 60 | isBetween :: Int -> (Int, Int) -> Bool 61 | isBetween x (a, b) = (a <= x) && (x <= b) || (b <= x) && (x <= a) 62 | 63 | intersect :: (Line, Int) -> (Line, Int) -> Maybe (Point, Int) 64 | intersect (HLine x1 x2 y, l1) (VLine x y1 y2, l2) 65 | | x == 0 && y == 0 = Nothing 66 | | isBetween x (x1, x2) && isBetween y (y1, y2) = 67 | Just (Point x y, l1 + l2 + abs (x1 - x) + abs (y1 - y)) 68 | | otherwise = Nothing 69 | intersect (VLine x y1 y2, l1) (HLine x1 x2 y, l2) = 70 | (HLine x1 x2 y, l2) `intersect` (VLine x y1 y2, l1) 71 | intersect _ _ = Nothing 72 | 73 | intersectAll :: [(Line, Int)] -> [(Line, Int)] -> [(Point, Int)] 74 | intersectAll wire1 wire2 = 75 | mapMaybe (uncurry intersect) [(l1, l2) | l1 <- wire1, l2 <- wire2] 76 | 77 | dist :: Point -> Int 78 | dist (Point x y) = abs x + abs y 79 | 80 | getIntersections text = intersectAll wire1 wire2 81 | where 82 | (paths1:paths2:_) = map (splitOn ",") (lines text) 83 | wire1 = getLines $ parseWire paths1 84 | wire2 = getLines $ parseWire paths2 85 | 86 | part1 intersections = minimum $ map (\(point, _) -> dist point) intersections 87 | 88 | part2 intersections = minimum $ map snd intersections 89 | 90 | verify expected actual 91 | | expected == actual = return () 92 | | otherwise = 93 | print $ 94 | "Value did not match, expected " ++ show expected ++ ", got " ++ show actual 95 | 96 | main = do 97 | let test0 = "R8,U5,L5,D3\nU7,R6,D4,L4" 98 | let test1 = 99 | "R75,D30,R83,U83,L12,D49,R71,U7,L72\nU62,R66,U55,R34,D71,R55,D58,R83" 100 | let test2 = 101 | "R98,U47,R26,D63,R33,U87,L62,D20,R33,U53,R51\nU98,R91,D20,R16,D67,R40,U7,R15,U6,R7" 102 | contents <- readFile "input.txt" 103 | let ix0 = getIntersections test0 104 | ix1 = getIntersections test1 105 | ix2 = getIntersections test2 106 | ix_final = getIntersections contents 107 | verify 159 (part1 ix1) 108 | verify 6 (part1 ix0) 109 | verify 135 (part1 ix2) 110 | print $ "Part 1: " ++ show (part1 ix_final) 111 | verify 30 (part2 ix0) 112 | verify 610 (part2 ix1) 113 | verify 410 (part2 ix2) 114 | print $ "Part 2: " ++ show (part2 ix_final) 115 | -------------------------------------------------------------------------------- /day07_old/day07.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE RecordWildCards #-} 2 | 3 | import Control.Exception 4 | import Control.Monad ((>=>)) 5 | import Data.Char 6 | import Data.IntMap.Strict (IntMap, (!)) 7 | import qualified Data.IntMap.Strict as IntMap 8 | import Data.Maybe 9 | import Data.Split 10 | import Debug.Trace 11 | 12 | 13 | type Register = IntMap.IntMap Int 14 | 15 | type Address = Int 16 | 17 | type Op = Int -> Int -> Int 18 | 19 | type Comp = Int -> Int -> Bool 20 | 21 | data Status = Running | Stop 22 | deriving (Eq, Show) 23 | 24 | data Program = Program 25 | { counter :: Address 26 | , register :: Register 27 | , inputs :: [Int] 28 | , outputs :: [Int] 29 | , status :: Status 30 | } deriving (Eq, Show) 31 | 32 | decode :: Int -> (Int, [Int]) 33 | decode inst = (read opcode, reverse $ map digitToInt paramModes) 34 | where 35 | s = show inst 36 | (paramModes, opcode) = splitAt (length s - 2) s 37 | 38 | 39 | mode :: Int -> Modes -> Int 40 | mode idx modes 41 | | idx < length modes = modes !! idx 42 | | otherwise = 0 43 | 44 | comp :: Comp -> Op 45 | comp op a b 46 | | a `op` b = 1 47 | | otherwise = 0 48 | 49 | lt :: Op 50 | lt = comp (<) 51 | 52 | eq :: Op 53 | eq = comp (==) 54 | 55 | type Modes = [Int] 56 | 57 | getReg :: Program -> Address -> Maybe Int 58 | getReg Program{..} = flip IntMap.lookup register . (counter +) 59 | 60 | loadWord :: Program -> Modes -> Address -> Maybe Int 61 | loadWord p@Program {..} modes x = (getReg p >=> load (mode (x - 1) modes)) x 62 | where 63 | load :: Int -> Address -> Maybe Int 64 | load mode val = 65 | case mode of 66 | 0 -> IntMap.lookup val register 67 | 1 -> Just val 68 | _ -> Nothing 69 | 70 | alu :: Program -> Modes -> Op -> Maybe Program 71 | alu p@Program {..} modes op = do 72 | a <- loadWord p modes 1 73 | b <- loadWord p modes 2 74 | addr <- getReg p 3 75 | let reg' = IntMap.insert addr (a `op` b) register 76 | return p{register=reg', counter=counter + 4} 77 | 78 | jump :: Program -> Modes -> Comp -> Maybe Program 79 | jump p@Program {..} modes comp = do 80 | val <- loadWord p modes 1 81 | addr <- loadWord p modes 2 82 | let counter' = if val `comp` 0 then addr else counter + 3 83 | return p{counter=counter'} 84 | 85 | store :: Program -> Modes -> Maybe Program 86 | store p@Program{..} modes = do 87 | x <- loadWord p modes 1 88 | return p{outputs=x : outputs, counter=counter + 2} 89 | 90 | safeHead :: [Int] -> Maybe (Int, [Int]) 91 | safeHead (x:xs) = Just (x, xs) 92 | safeHead _ = Nothing 93 | 94 | load :: Program -> Maybe Program 95 | load p@Program{..} = do 96 | (x, xs) <- safeHead inputs 97 | dest <- getReg p 1 98 | let reg' = IntMap.insert dest x register 99 | return p{register=reg', inputs=xs} 100 | 101 | 102 | step :: Program -> Maybe Program 103 | step p@Program{status=Stop} = Just p 104 | step p@Program{..} = do 105 | (opcode, modes) <- decode <$> getReg p 0 106 | let alu' = alu p modes 107 | jump' = jump p modes 108 | case opcode of 109 | 1 -> alu' (+) 110 | 2 -> alu' (*) 111 | 3 -> load p 112 | 4 -> store p modes 113 | 5 -> jump' (/=) -- jump-if-true 114 | 6 -> jump' (==) -- jump-if-false 115 | 7 -> alu' lt -- less than 116 | 8 -> alu' eq -- equals 117 | 99 -> Just p{status=Stop} 118 | _ -> Nothing 119 | 120 | initRegister :: [Int] -> IntMap Int 121 | initRegister = IntMap.fromList . zip [0 ..] 122 | 123 | initProgram :: [Int] -> [Int] -> Program 124 | initProgram memory inputs = Program 125 | { register=initRegister memory 126 | , inputs=reverse inputs 127 | , outputs=[] 128 | , counter=0 129 | , status=Running 130 | } 131 | 132 | run :: Program -> Maybe Program 133 | run p@Program {status=Stop, ..} = Just p 134 | run p = step p >>= run 135 | 136 | verifyProg :: Monad m => Program -> [Int] -> m () 137 | verifyProg prog expected = 138 | assert ((register <$> run prog) == Just (initRegister expected)) return () 139 | 140 | verifyOutput :: Monad m => Program -> Int -> m () 141 | verifyOutput prog expected = 142 | assert ((outputs <$> run prog) == Just [expected]) return () 143 | 144 | main :: IO () 145 | main = do 146 | contents <- readFile "input2.txt" 147 | let prog = initProgram $ map read (splitOn "," contents) :: [Int] 148 | print $ outputs <$> run (prog [1]) 149 | print $ outputs <$> run (prog [5]) 150 | -------------------------------------------------------------------------------- /day05/day05.hs: -------------------------------------------------------------------------------- 1 | import Control.Exception 2 | import Control.Monad ((>=>)) 3 | import Data.Char 4 | import Data.IntMap.Strict (IntMap, (!)) 5 | import qualified Data.IntMap.Strict as IntMap 6 | import Data.List.Split 7 | import Data.Maybe 8 | import Debug.Trace 9 | 10 | decode :: Int -> (Int, [Int]) 11 | decode inst = (read opcode, reverse $ map digitToInt paramModes) 12 | where 13 | s = show inst 14 | (paramModes, opcode) = splitAt (length s - 2) s 15 | 16 | load :: IntMap Int -> Int -> Int -> Maybe Int 17 | load prog mode val = 18 | case mode of 19 | 0 -> IntMap.lookup val prog 20 | 1 -> Just val 21 | _ -> Nothing 22 | 23 | mode :: Int -> [Int] -> Int 24 | mode idx modes 25 | | idx < length modes = modes !! idx 26 | | otherwise = 0 27 | 28 | eval :: IntMap Int -> Int -> [Int] -> [Int] -> Maybe ([Int], IntMap Int) 29 | eval prog counter input output = do 30 | let getReg = flip IntMap.lookup prog 31 | (opcode, modes) <- fmap decode (getReg counter) 32 | let getMode = flip mode modes 33 | let dest = getReg (counter + 3) 34 | case opcode of 35 | 3 36 | -- load input 37 | -> do 38 | let (x:xs) = input 39 | dest <- getReg (counter + 1) 40 | eval (IntMap.insert dest x prog) (counter + 2) xs output 41 | 4 42 | -- store output 43 | -> do 44 | p <- getReg (counter + 1) 45 | val <- load prog (getMode 0) p 46 | eval prog (counter + 2) input (val : output) 47 | 5 48 | -- jump-if-true 49 | -> do 50 | a <- (getReg >=> load prog (getMode 0)) (counter + 1) 51 | b <- (getReg >=> load prog (getMode 1)) (counter + 2) 52 | eval 53 | prog 54 | (if a /= 0 55 | then b 56 | else counter + 3) 57 | input 58 | output 59 | 6 60 | -- jump-if-false 61 | -> do 62 | a <- (getReg >=> load prog (getMode 0)) (counter + 1) 63 | b <- (getReg >=> load prog (getMode 1)) (counter + 2) 64 | eval 65 | prog 66 | (if a == 0 67 | then b 68 | else counter + 3) 69 | input 70 | output 71 | 7 72 | -- less than 73 | -> do 74 | a <- (getReg >=> load prog (getMode 0)) (counter + 1) 75 | b <- (getReg >=> load prog (getMode 1)) (counter + 2) 76 | dest <- getReg (counter + 3) 77 | eval 78 | (IntMap.insert 79 | dest 80 | (if a < b 81 | then 1 82 | else 0) 83 | prog) 84 | (counter + 4) 85 | input 86 | output 87 | 8 88 | -- equals 89 | -> do 90 | a <- (getReg >=> load prog (getMode 0)) (counter + 1) 91 | b <- (getReg >=> load prog (getMode 1)) (counter + 2) 92 | dest <- getReg (counter + 3) 93 | eval 94 | (IntMap.insert 95 | dest 96 | (if a == b 97 | then 1 98 | else 0) 99 | prog) 100 | (counter + 4) 101 | input 102 | output 103 | 99 -> Just (reverse output, prog) 104 | _ -> do 105 | a <- (getReg >=> load prog (getMode 0)) (counter + 1) 106 | b <- (getReg >=> load prog (getMode 1)) (counter + 2) 107 | dest <- getReg (counter + 3) 108 | let exec op = 109 | eval (IntMap.insert dest (a `op` b) prog) (counter + 4) input output 110 | case opcode of 111 | 1 -> exec (+) 112 | 2 -> exec (*) 113 | _ -> Nothing 114 | 115 | initProg :: [Int] -> IntMap Int 116 | initProg = IntMap.fromList . zip [0 ..] 117 | 118 | run prog input = eval (initProg prog) 0 (reverse input) [] 119 | 120 | verifyProg prog input expected = 121 | assert (snd (fromJust $ run prog input) == initProg expected) return () 122 | 123 | verifyOutput prog input expected = 124 | assert (fst (fromJust $ run prog input) == expected) return () 125 | 126 | main = do 127 | let test1 = [3, 0, 4, 0, 99] 128 | test2 = [1002, 4, 3, 4, 33] 129 | test3 = [3, 9, 8, 9, 10, 9, 4, 9, 99, -1, 8] 130 | test4 = [3, 9, 7, 9, 10, 9, 4, 9, 99, -1, 8] 131 | test5 = [3, 3, 1108, -1, 8, 3, 4, 3, 99] 132 | test6 = [3, 3, 1107, -1, 8, 3, 4, 3, 99] 133 | verifyOutput test1 [1] [1] 134 | verifyProg test2 [1] [1002, 4, 3, 4, 99] 135 | verifyOutput test3 [8] [1] 136 | verifyOutput test4 [8] [0] 137 | verifyOutput test5 [7] [0] 138 | verifyOutput test6 [1] [1] 139 | contents <- readFile "input.txt" 140 | let prog = map read (splitOn "," contents) :: [Int] 141 | print $ fmap fst (run prog [1]) 142 | print $ fmap fst (run prog [5]) 143 | -------------------------------------------------------------------------------- /day07/src/day07.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE RecordWildCards #-} 2 | 3 | import Control.Applicative 4 | import Control.Exception 5 | import Control.Monad ((<=<)) 6 | import Control.Monad.State.Lazy 7 | import Data.Char 8 | import Data.IntMap.Lazy (IntMap, (!)) 9 | import qualified Data.IntMap.Lazy as IntMap 10 | import Data.List.Split 11 | import Data.Maybe 12 | import Debug.Trace 13 | import Text.Read (readMaybe) 14 | 15 | type Register = IntMap.IntMap Int 16 | 17 | type Address = Int 18 | 19 | type Operation = Int -> Int -> Int 20 | 21 | type Comp = Int -> Int -> Bool 22 | 23 | data Status = Running | Stop 24 | deriving (Eq, Show) 25 | 26 | type Execution a = StateT Program Maybe a 27 | 28 | data Program = Program 29 | { counter :: Address 30 | , register :: Register 31 | , inputs :: [Int] 32 | , outputs :: [Int] 33 | , status :: Status 34 | } deriving (Eq, Show) 35 | 36 | 37 | data Mode = Immediate | Position 38 | deriving (Eq, Show) 39 | 40 | 41 | instance Show Op where 42 | show (Alu _ m1 m2) = "Alu " ++ show m1 ++ " " ++ show m2 43 | show (Jump _ m1 m2) = "Jump " ++ show m1 ++ " " ++ show m2 44 | show Input = "Input" 45 | show (Output m1) = "Output " ++ show m1 46 | show Terminate = "Terminate" 47 | 48 | data Op 49 | = Alu Operation Mode Mode 50 | | Jump Comp Mode Mode 51 | | Input 52 | | Output Mode 53 | | Terminate 54 | 55 | 56 | (##) :: [a] -> Int -> Maybe a 57 | (x:_) ## 0 = Just x 58 | [] ## _ = Nothing 59 | (x:xs) ## n = xs ## (n - 1) 60 | 61 | 62 | toModes :: Int -> Maybe Mode 63 | toModes 0 = Just Position 64 | toModes 1 = Just Immediate 65 | toModes _ = Nothing 66 | 67 | prependZeros :: String -> String 68 | prependZeros xs 69 | | length xs >= 5 = xs 70 | | otherwise = prependZeros ('0' : xs) 71 | 72 | decode :: Int -> Maybe Op 73 | decode inst = do 74 | let (op', modes') = splitAt 2 . reverse . prependZeros $ show inst 75 | op <- readMaybe . reverse $ op' 76 | modes <- traverse (toModes . digitToInt) modes' 77 | let m1 = modes ## 0 78 | let m2 = modes ## 1 79 | let m3 = modes ## 2 80 | case op of 81 | 1 -> liftA2 (Alu (+)) m1 m2 82 | 2 -> liftA2 (Alu (*)) m1 m2 83 | 3 -> Just Input 84 | 4 -> fmap Output m1 85 | 5 -> liftA2 (Jump (/=)) m1 m2 86 | 6 -> liftA2 (Jump (==)) m1 m2 87 | 7 -> liftA2 (Alu lt) m1 m2 88 | 8 -> liftA2 (Alu eq) m1 m2 89 | 99 -> Just Terminate 90 | _ -> Nothing 91 | 92 | comp :: Comp -> Operation 93 | comp op a b 94 | | a `op` b = 1 95 | | otherwise = 0 96 | 97 | lt :: Operation 98 | lt = comp (<) 99 | 100 | eq :: Operation 101 | eq = comp (==) 102 | 103 | getReg :: Address -> Execution Int 104 | getReg addr = do 105 | reg <- gets register 106 | lift (IntMap.lookup addr reg) 107 | 108 | load :: Mode -> Address -> Execution Int 109 | load Position addr = load Immediate addr >>= getReg 110 | load Immediate addr = (+ addr) <$> gets counter >>= getReg 111 | 112 | store :: Address -> Int -> Execution () 113 | store addr val = modify insertVal 114 | where 115 | insertVal :: Program -> Program 116 | insertVal program = let r' = IntMap.insert addr val (register program) 117 | in program{register=r'} 118 | 119 | increaseCounter :: Int -> Execution () 120 | increaseCounter i = modify (\p -> p{counter=counter p + i}) 121 | 122 | setCounter :: Int -> Execution () 123 | setCounter i = modify (\p -> p{counter=i}) 124 | 125 | alu :: Operation -> (Mode, Mode) -> Execution () 126 | alu op (m1, m2) = do 127 | a <- load m1 1 128 | b <- load m2 2 129 | addr <- load Immediate 3 130 | increaseCounter 4 131 | store addr (a `op` b) 132 | 133 | jump :: Comp -> (Mode, Mode) -> Execution () 134 | jump comp (m1, m2) = do 135 | val <- load m1 1 136 | addr <- load m2 2 137 | if val `comp` 0 then setCounter addr else increaseCounter 3 138 | 139 | output :: Mode -> Execution () 140 | output mode = do 141 | x <- load mode 1 142 | modify (\p -> p{outputs = x : outputs p}) 143 | increaseCounter 2 144 | 145 | safeHead :: [Int] -> Maybe (Int, [Int]) 146 | safeHead (x:xs) = Just (x, xs) 147 | safeHead _ = Nothing 148 | 149 | input :: Execution () 150 | input = do 151 | (x, xs) <- gets inputs >>= lift . safeHead 152 | modify (\p -> p{inputs=xs}) 153 | dest <- load Immediate 1 154 | store dest x 155 | increaseCounter 2 156 | 157 | step :: Execution () 158 | step = do 159 | s <- gets status 160 | case s of 161 | Stop -> return () 162 | _ -> do 163 | reg <- gets register 164 | op <- load Immediate 0 >>= lift . decode 165 | case op of 166 | Alu op m1 m2 -> alu op (m1, m2) 167 | Input -> input 168 | Jump comp m1 m2 -> jump comp (m1, m2) 169 | Output mode -> output mode 170 | Terminate -> modify (\p -> p{status=Stop}) 171 | 172 | initRegister :: [Int] -> Register 173 | initRegister = IntMap.fromList . zip [0 ..] 174 | 175 | initProgram :: [Int] -> [Int] -> Program 176 | initProgram memory inputs = Program 177 | { register=initRegister memory 178 | , inputs=inputs 179 | , outputs=[] 180 | , counter=0 181 | , status=Running 182 | } 183 | 184 | run :: Program -> Maybe Program 185 | run p@Program {status=Stop, ..} = Just p 186 | run p = execStateT step p >>= run 187 | 188 | verifyProg :: Monad m => Program -> [Int] -> m () 189 | verifyProg prog expected = 190 | assert ((register <$> run prog) == Just (initRegister expected)) return () 191 | 192 | verifyOutput :: Monad m => Program -> Int -> m () 193 | verifyOutput prog expected = 194 | assert ((outputs <$> run prog) == Just [expected]) return () 195 | 196 | loadFile :: String -> IO [Int] 197 | loadFile = fmap (map read . splitOn ",") . readFile 198 | 199 | runDiagnostic :: Program -> [Program] 200 | runDiagnostic = recurse [] 201 | where 202 | recurse :: [Program] -> Program -> [Program] 203 | recurse xs p@Program{status=Stop} = xs 204 | recurse xs p = let x = execStateT step p 205 | in case x of 206 | Just p -> recurse (p:xs) p 207 | Nothing -> xs 208 | main :: IO () 209 | main = do 210 | day05 <- loadFile "day05.txt" 211 | prog <- return [1,9,10,3,2,3,11,0,99,30,40,50] 212 | let prog05 = initProgram day05 [5] 213 | print $ outputs <$> (run prog05) 214 | -------------------------------------------------------------------------------- /day06/input.txt: -------------------------------------------------------------------------------- 1 | WGB)S14 2 | WN4)27C 3 | 18L)M18 4 | 1HY)6ZP 5 | TQ9)KQ6 6 | HQ3)HH1 7 | FLC)F1Z 8 | D6R)ZPC 9 | 2VD)GK3 10 | YY3)3TP 11 | PBL)3CK 12 | 5K4)CB5 13 | V5M)CNN 14 | L4T)RHS 15 | HHH)66F 16 | Q3Y)DTL 17 | DGN)YY3 18 | CCT)L3B 19 | Z6X)FM2 20 | 2QQ)VK9 21 | MX3)C9J 22 | 4JK)BPX 23 | 8BP)N13 24 | PBW)6Z6 25 | 2LT)DT9 26 | JHX)GXM 27 | 5LW)BHQ 28 | DNK)ZBT 29 | 29Z)T9D 30 | WNP)TDC 31 | S38)GL6 32 | DW9)V2F 33 | 4MG)3FW 34 | Z9Z)CPK 35 | FKL)QNH 36 | 55D)HT2 37 | D1D)N4Q 38 | Y7W)1Y8 39 | SFQ)79W 40 | JSR)62W 41 | 4WN)J18 42 | VK9)J2H 43 | LS5)DCX 44 | 6LR)P4X 45 | HDV)DGQ 46 | 1K9)KD1 47 | 2PX)17C 48 | KSB)GL8 49 | B4S)VTV 50 | ZW1)KNR 51 | BVH)43P 52 | VKP)6L3 53 | P5K)MHR 54 | XHR)STT 55 | WBG)5X5 56 | HZF)8JQ 57 | B47)NW4 58 | J5V)3ZW 59 | KGP)VVR 60 | 24K)PK8 61 | 31V)LXC 62 | 5XG)RHP 63 | P1G)HN8 64 | R76)3GY 65 | 5CH)17Q 66 | TVC)XJM 67 | 598)RD3 68 | J66)LKC 69 | 4DY)YSQ 70 | M4Y)NLL 71 | SMP)M2M 72 | TBR)WNP 73 | K22)KGP 74 | MQ5)8MN 75 | B9Q)6HQ 76 | P9S)X92 77 | TJK)ZQK 78 | XS7)7KL 79 | H6J)DX1 80 | MTP)3Z6 81 | B17)B7P 82 | S12)PC2 83 | 47V)5KW 84 | KCY)HWP 85 | FB2)S38 86 | V5M)FNT 87 | GXM)QPR 88 | HXR)2R2 89 | 2LV)NDP 90 | 6HQ)12S 91 | 22P)4HL 92 | T8Q)9FB 93 | 8YW)TVZ 94 | DR1)NNN 95 | 9TH)87Z 96 | 79W)TM2 97 | 5GB)HQM 98 | 1HY)4WN 99 | LFV)RYJ 100 | YCN)ZMK 101 | 8SR)SB3 102 | P9H)PH9 103 | ZGQ)T3J 104 | KWW)1HY 105 | TLF)RPG 106 | PFD)HZR 107 | 9SF)7PY 108 | DCX)VCC 109 | D1R)2RB 110 | GXC)NN9 111 | ZZW)SCC 112 | G44)Q8D 113 | 923)3J2 114 | KY2)8F4 115 | 1XQ)7LD 116 | GHX)Q6M 117 | TZ5)V32 118 | LM9)1XK 119 | Q7N)Z7H 120 | YKD)73H 121 | 9RZ)C2Q 122 | 5KN)P1G 123 | 3FJ)L73 124 | ZPC)VYT 125 | Y7D)FFY 126 | C8W)J1Y 127 | X5T)55D 128 | Z3F)GK8 129 | WRS)PRR 130 | T9M)JK2 131 | 81P)5WT 132 | 7KL)5BK 133 | S3R)VCD 134 | 56L)D1R 135 | PR2)92L 136 | 91F)2F4 137 | ND4)PJ6 138 | 9KY)YD4 139 | CLH)5D7 140 | J2F)L7Z 141 | M4Y)PYG 142 | 891)P34 143 | VV6)18L 144 | RQQ)X8P 145 | 7SR)8G6 146 | WJ8)CDL 147 | 9FB)TXD 148 | RKK)2H5 149 | 3W8)2QQ 150 | 27C)YFC 151 | RZZ)91F 152 | 4CP)BWH 153 | T4L)LS5 154 | 788)G7S 155 | 47V)3W8 156 | FGK)719 157 | 16Q)4KW 158 | 5H6)PC9 159 | KGS)TBR 160 | 44Y)BVH 161 | GMF)VFM 162 | LKC)PM4 163 | DPL)DXS 164 | 2WD)X5T 165 | XWX)NYR 166 | N44)Y36 167 | 72S)56L 168 | W25)4MG 169 | P9S)HBC 170 | W84)3YP 171 | NW4)S78 172 | 58Y)LDB 173 | QJ9)VV1 174 | 5D3)4Q7 175 | T3J)5M4 176 | 394)ZW7 177 | JXL)QVK 178 | 7KL)FTL 179 | 885)ZGQ 180 | 58Y)8SR 181 | GXN)PBW 182 | HH1)JB4 183 | H6J)W95 184 | VYK)SQS 185 | CCS)7CZ 186 | PJ7)NLR 187 | 2VW)MSP 188 | ZWK)H6X 189 | HJ4)C1S 190 | H41)1L3 191 | 8B9)64N 192 | RZR)WBJ 193 | FNT)VL7 194 | K5M)S5Q 195 | XJM)TC7 196 | QWT)7Q5 197 | 43P)MY2 198 | YP7)51N 199 | TDX)FWZ 200 | DB3)NCK 201 | 37M)H2L 202 | Z3X)XRS 203 | SGV)R2T 204 | Y2F)63M 205 | ZVY)JTX 206 | DJB)KQD 207 | 848)FQP 208 | SX3)FM5 209 | PH9)ZPG 210 | 75S)Z9L 211 | GPD)Y7D 212 | 9Y6)52N 213 | SL4)S3R 214 | 4TH)T6F 215 | K4V)D8V 216 | 89S)18F 217 | GDN)WN4 218 | 6HT)TQZ 219 | V1Q)JVG 220 | R55)2LC 221 | KH3)NT5 222 | Q53)3DN 223 | SRV)JND 224 | XMC)MKK 225 | T5J)6HT 226 | HZR)M1M 227 | P34)3RY 228 | HF6)SD2 229 | PTM)C9X 230 | 3MZ)T9M 231 | R76)MFF 232 | B9Y)3MC 233 | NFG)5FC 234 | M63)4CP 235 | FRG)PVQ 236 | 58Z)GDM 237 | ZT8)4L5 238 | F5B)KF3 239 | SQT)NTZ 240 | M2M)252 241 | 35Y)5WF 242 | C9J)8BP 243 | W8H)F78 244 | H8Z)2VW 245 | 91P)5FP 246 | VTV)YN7 247 | 2KM)1K9 248 | KSX)TR8 249 | 9DK)XD6 250 | MFF)KQR 251 | 414)6L9 252 | FQ7)T5K 253 | G8M)WPX 254 | 794)FMS 255 | WZV)XS7 256 | VVR)5CH 257 | R8G)9RH 258 | B4D)2RT 259 | PJ6)GWB 260 | 63M)NHF 261 | 8G7)8B9 262 | QP5)9ZW 263 | FW6)CDM 264 | S5Q)172 265 | T24)TPD 266 | YRT)GMF 267 | 1TJ)SGV 268 | RV3)C3D 269 | 661)MHS 270 | QYT)D2K 271 | T49)MFP 272 | GY7)T2Q 273 | 686)Z4G 274 | J49)R9L 275 | R5S)67X 276 | L7Z)5RM 277 | RPP)WG9 278 | 5KW)2KM 279 | 5N2)Y7W 280 | Z3X)JFD 281 | KD8)4H5 282 | 5MP)RVK 283 | 12S)S2Y 284 | TPD)D5F 285 | 51N)81P 286 | DCH)SGQ 287 | L6N)VKP 288 | 2XQ)6LR 289 | 3DN)S3L 290 | VS4)83N 291 | 8DJ)WZP 292 | DCX)FX1 293 | SF9)Z3F 294 | R49)S99 295 | D1C)794 296 | TKN)L83 297 | 21R)GP3 298 | 5RM)TG3 299 | ZMK)R49 300 | 1QT)152 301 | 9DX)GXC 302 | GYC)TQ9 303 | JND)LMK 304 | D8Z)SCW 305 | VNZ)VS4 306 | C1S)9RZ 307 | LKF)D8Z 308 | G4J)R44 309 | 92L)J66 310 | 88P)657 311 | 8Z5)R55 312 | VV1)KRY 313 | N44)2QK 314 | KBC)KKG 315 | 91P)L6N 316 | SVH)7W3 317 | P9Z)34H 318 | BWH)9TH 319 | JNX)RZZ 320 | YFG)ZT8 321 | DSM)FF3 322 | BMK)ZR6 323 | 7W3)V82 324 | T9D)H2S 325 | 2QF)PFD 326 | NDQ)F13 327 | ZVB)MX6 328 | KRY)7FB 329 | KKG)HJ4 330 | QNH)MFQ 331 | 5X5)VQM 332 | HQM)HF6 333 | HLT)TD2 334 | WV4)FWH 335 | N2T)5B5 336 | D1R)P89 337 | HKT)3MZ 338 | ZQK)1DK 339 | QQQ)FLC 340 | 73Z)TTM 341 | ZZW)769 342 | 8G7)TYL 343 | MFP)WMS 344 | RQS)2YC 345 | NLL)JHX 346 | KCY)CSP 347 | 9F8)51H 348 | SGQ)B27 349 | 4KM)VYK 350 | JDY)MTW 351 | T8Q)DB3 352 | 1VL)VV6 353 | VV5)B4D 354 | SPF)JR5 355 | LYS)6CK 356 | YMK)2VD 357 | TD2)1VL 358 | JKH)QHX 359 | VD4)58J 360 | 9QQ)HKL 361 | 8JP)HQ3 362 | NHS)31S 363 | 81Z)Q5W 364 | R7Q)Z9M 365 | WMS)ZK2 366 | 3J2)GY7 367 | MFQ)CLH 368 | S14)934 369 | HY7)YBT 370 | 4SY)63F 371 | NQF)PPQ 372 | T9W)RZR 373 | WL2)6QM 374 | LZV)WRQ 375 | TVZ)T9P 376 | 4X5)GN5 377 | NQ8)FPQ 378 | J5J)K51 379 | Y8T)WGM 380 | FPQ)B53 381 | 1XK)TKX 382 | XDW)72V 383 | WW8)9QQ 384 | XX7)Q7N 385 | CDM)GHX 386 | VCC)HPP 387 | QRK)56B 388 | MTW)2QT 389 | 7V5)58Z 390 | PYY)T24 391 | 9HB)J8F 392 | TTM)PTB 393 | FF3)ZY3 394 | ZW7)D1D 395 | T4H)ZTG 396 | 2PW)DSM 397 | 9WB)4TH 398 | 17C)FKX 399 | T6F)QP3 400 | G6R)XHR 401 | H5T)QYT 402 | DX1)Q9L 403 | GJF)ZF3 404 | LJP)JXL 405 | QHX)3XY 406 | DNF)8KQ 407 | 8Q1)NDQ 408 | GP3)6MY 409 | FPQ)QQQ 410 | XRS)923 411 | Q6M)7BS 412 | K21)B47 413 | TQZ)WJ4 414 | 9PB)3PQ 415 | 8G6)X7M 416 | L3B)YOU 417 | L5V)G2L 418 | B8Y)JVS 419 | GL6)MTP 420 | 9QZ)NRN 421 | 486)T8Q 422 | HNN)PNM 423 | NFK)B4S 424 | G9C)LHT 425 | 4K9)SL4 426 | 8X5)179 427 | VQM)47V 428 | CNJ)J4R 429 | ZD5)2PX 430 | 9TQ)X9Q 431 | Q3Q)9DK 432 | 17Q)1KX 433 | 5GN)24K 434 | K5Q)1NF 435 | LCK)9WB 436 | TYL)PYL 437 | 7XG)R2L 438 | LXC)ZWK 439 | Q62)SPF 440 | 89C)N7Z 441 | GK8)GR7 442 | 6X1)5N2 443 | XM8)8Q1 444 | MCD)GXQ 445 | S2Y)N7G 446 | CB5)C8W 447 | NHF)44B 448 | QPR)GF5 449 | HGX)YMY 450 | 3FW)2LV 451 | 5WF)RQQ 452 | 841)N31 453 | Q9L)876 454 | WQ8)HZ7 455 | 6K1)QVC 456 | C2T)FQX 457 | J3M)HLT 458 | H2S)K5Q 459 | STQ)8ZF 460 | VDX)NQF 461 | YSR)G8M 462 | CSL)NLF 463 | MHS)3FH 464 | YN7)VWC 465 | RSW)X11 466 | FXS)L54 467 | YBT)HX4 468 | BHQ)FRG 469 | 83H)K4Q 470 | NT5)2ZB 471 | GWB)4K9 472 | YMY)5KN 473 | 4Q7)C3G 474 | D3J)HZF 475 | 32D)GN7 476 | VGG)G3D 477 | LVG)JXR 478 | 25V)GDN 479 | L6V)KL8 480 | FW2)STQ 481 | V6H)8G7 482 | COM)CB6 483 | 6Z6)SQT 484 | W81)6M3 485 | D2K)XF6 486 | 2NX)9KY 487 | KRQ)LKF 488 | P1B)VVQ 489 | QTV)Q3Y 490 | DTZ)ZLY 491 | R3T)FQ7 492 | D92)72S 493 | H8N)9Y6 494 | FWZ)WGB 495 | VQW)LHJ 496 | 2HB)848 497 | 9ZW)NT8 498 | NLR)QTV 499 | 31V)DSZ 500 | 92J)WXY 501 | 8LK)QQ3 502 | 769)ZD5 503 | 8L9)T5J 504 | TB2)V5M 505 | VZQ)57T 506 | Z7H)JMR 507 | 94D)YCN 508 | ZPF)6WK 509 | M1F)6C2 510 | MHV)ZCS 511 | Q53)FBC 512 | RPG)P3N 513 | RHS)JDY 514 | FTL)FB2 515 | J47)R3T 516 | Y9S)4JK 517 | ZVY)TK6 518 | LTX)BM5 519 | D8V)3R6 520 | J18)S19 521 | PVQ)WL2 522 | ZPV)QFW 523 | 719)CSV 524 | XK9)9Q9 525 | BM5)L5V 526 | LDF)WZT 527 | MSP)DTZ 528 | HRQ)JBG 529 | 19C)GSP 530 | GPB)HGX 531 | 2F4)8HL 532 | 886)C8J 533 | ZF3)LM9 534 | NQ1)394 535 | WM9)M79 536 | PM4)GNT 537 | 6J4)ML2 538 | 5WT)HQS 539 | KQD)5K4 540 | JBT)V1Q 541 | JVS)DDT 542 | 3G2)52L 543 | 8ZF)D6R 544 | 4BQ)5H6 545 | G7T)7T6 546 | ZY3)83H 547 | HYC)G9C 548 | MX6)XC9 549 | 2NW)2SH 550 | YXJ)JSR 551 | QNH)YJN 552 | TG3)886 553 | N7Z)G98 554 | 5D7)KNW 555 | 8TN)KH3 556 | C78)TSW 557 | 87Z)DFM 558 | QGG)Q53 559 | NRN)YP7 560 | TTB)C2T 561 | ZLY)25P 562 | 7KS)D5X 563 | LNX)CNJ 564 | QVK)YMK 565 | CNN)N43 566 | 5Q9)MWG 567 | SCC)XFV 568 | 885)G7T 569 | 4BS)4BQ 570 | N4Q)Z6X 571 | FQX)7W4 572 | MLL)NF8 573 | 52N)PZ2 574 | DNF)KBC 575 | 6C2)CCS 576 | LZ8)P1B 577 | CSV)686 578 | PZ2)KKC 579 | JMR)327 580 | 3TP)N6L 581 | 3W8)YFG 582 | S62)J5V 583 | FF3)VXL 584 | 4X4)MHQ 585 | 3TP)7Z7 586 | L83)VDN 587 | Q8D)2HB 588 | JB4)5LR 589 | VYT)SAN 590 | L54)X63 591 | 15J)XF2 592 | FWZ)WLR 593 | R44)K5M 594 | TK6)Q5J 595 | J81)QP5 596 | 114)BGP 597 | QQ3)PJ7 598 | D5F)HNN 599 | MFF)WW8 600 | J18)MP3 601 | 9JN)M8G 602 | 2YC)CSL 603 | R2T)4TS 604 | ZBT)WQ8 605 | XFV)MPD 606 | R9S)XDW 607 | 8HL)99X 608 | 4MG)2QF 609 | 8X5)BMK 610 | CN7)KSB 611 | YJN)44Y 612 | X11)WWY 613 | 5MP)VDX 614 | R2L)PFY 615 | 6ZP)HPW 616 | WGM)GPB 617 | WCZ)KCY 618 | NYR)TKN 619 | 1L3)SKC 620 | MND)S5K 621 | 17N)2D1 622 | VL7)16Q 623 | 5FP)J5J 624 | NBL)TLF 625 | QDV)Z9Z 626 | 2S1)VXW 627 | K22)G6R 628 | DTL)9Z8 629 | BXN)YXJ 630 | VYW)LNX 631 | WJ4)4LM 632 | JTX)DPL 633 | SLM)DNF 634 | YM4)J37 635 | 4L5)BF4 636 | 2RT)8DD 637 | FNB)KD8 638 | PK8)9PD 639 | RLR)4SY 640 | TM2)661 641 | PQ6)2FF 642 | 92J)XMC 643 | GDM)21R 644 | ZTG)VV5 645 | X3B)ZZW 646 | 5XQ)H6J 647 | WTL)W1N 648 | PNM)H8Z 649 | 6MY)CG5 650 | 72V)RLR 651 | 3R6)WCZ 652 | PF8)YRM 653 | HPY)88T 654 | X8P)MHN 655 | 7LY)6VJ 656 | 2FF)C9G 657 | K4Q)4BS 658 | X63)2WD 659 | XM8)R8Q 660 | G98)Z3X 661 | 44B)8DJ 662 | PWZ)V1P 663 | MDD)7ZX 664 | RRD)T49 665 | YBJ)DBX 666 | GXQ)BXP 667 | 6FX)88P 668 | WXZ)H22 669 | 18F)WTL 670 | NQF)885 671 | L4T)XM2 672 | V82)4DY 673 | 6N6)TDX 674 | 172)QRK 675 | N6L)23T 676 | CSP)5MP 677 | GLG)9TQ 678 | 9P6)R76 679 | W1N)N3F 680 | R8G)JZ1 681 | H2L)F2D 682 | TGT)C9S 683 | 7BS)2XQ 684 | FWH)TVM 685 | 23T)K3L 686 | WQX)37M 687 | 3ZW)QH7 688 | BGP)FW6 689 | YFC)FGH 690 | JCF)94D 691 | WRQ)9JN 692 | GN5)6RM 693 | V6H)QGG 694 | C1S)XK9 695 | FFY)9SF 696 | WPX)HKT 697 | 7Y1)NBL 698 | 6RN)GPD 699 | NYJ)YDT 700 | 934)FKL 701 | P3N)FXS 702 | ZQS)KXC 703 | 4KW)PVJ 704 | FMS)V26 705 | NT8)WM9 706 | 7Z7)G4J 707 | NN9)2TT 708 | VXW)DJB 709 | C97)Q3Q 710 | VVQ)486 711 | CB6)DGN 712 | DGQ)WMN 713 | FM5)GJF 714 | 6YY)DPN 715 | DDT)814 716 | KF3)SFQ 717 | G7S)TTB 718 | R4C)S12 719 | R8Q)35Y 720 | GXN)JKH 721 | J2H)K22 722 | F5B)7LY 723 | NCK)YSR 724 | SMP)KY2 725 | P4X)X3B 726 | DR5)LZ8 727 | 8JQ)ZPV 728 | WG9)SX3 729 | NDQ)LM2 730 | 32S)LFV 731 | K51)ND4 732 | DP3)QDV 733 | 2W7)CCT 734 | RSK)YH6 735 | 9NZ)NSB 736 | K3L)RV3 737 | HN8)414 738 | 92N)75S 739 | 61M)598 740 | ZR6)53T 741 | J8F)TB2 742 | H22)5YX 743 | HSJ)M63 744 | 4KW)5GB 745 | HR7)89C 746 | FQP)15J 747 | TZ5)LYS 748 | 5FP)WG4 749 | 4HL)PBL 750 | C8J)D1C 751 | TS3)83C 752 | C3G)1QT 753 | GZD)DNK 754 | 2RB)KSF 755 | BCD)SF9 756 | 327)9QZ 757 | 4FF)ZQS 758 | 6L9)82F 759 | TJK)123 760 | X9M)FMY 761 | R92)TV1 762 | CDL)2PW 763 | 7ZX)58Y 764 | C2N)H5T 765 | 8MN)TH2 766 | GN7)G44 767 | HKL)61M 768 | XD6)1C9 769 | ZCS)NQ8 770 | 2L8)QGH 771 | DFC)XX7 772 | S5K)XM8 773 | 58J)8L9 774 | PRR)4KM 775 | 6XT)N2T 776 | FM2)7Y1 777 | V26)HR7 778 | 2TT)91P 779 | 88F)ZW1 780 | JBG)891 781 | WZT)VZQ 782 | PYG)NHS 783 | 2QT)P9H 784 | FB2)9QT 785 | MP3)PQ6 786 | WZV)YBJ 787 | H53)VYW 788 | N2T)VQW 789 | ZK2)6RT 790 | SQS)5XQ 791 | DPN)W8H 792 | TSW)2L8 793 | 73H)R7Q 794 | F1Z)B9Q 795 | M8G)9KS 796 | NSB)H41 797 | WBJ)THR 798 | KSF)KGS 799 | PXH)3BS 800 | 4NT)ZRV 801 | VNZ)8X5 802 | 98S)DR1 803 | 3XY)TJK 804 | JNX)P9Z 805 | F4P)6YY 806 | VRT)VKV 807 | TVM)92N 808 | WLR)S62 809 | D5X)ZVB 810 | 152)9P6 811 | F2D)PN3 812 | 2R2)D6K 813 | ZRV)2NX 814 | 67X)TS3 815 | HWP)YBD 816 | 5FC)SRV 817 | X92)CQR 818 | 8N9)DFC 819 | Q5J)H8N 820 | GGG)8LK 821 | PPQ)841 822 | 6RT)WJ8 823 | KQR)788 824 | 92N)Q62 825 | W7S)98S 826 | S19)NFK 827 | VRM)ZVY 828 | GL8)DCH 829 | 4YM)17N 830 | F13)D3J 831 | QVC)VGG 832 | 31S)J81 833 | 934)93X 834 | Q21)R4C 835 | TH2)HQ4 836 | 1C9)114 837 | 83N)X5B 838 | S3L)T4L 839 | SD2)ZWX 840 | SC1)6K1 841 | TXD)ZPF 842 | 3GY)NQ1 843 | Z9M)9NS 844 | D6R)7V5 845 | WG4)C2N 846 | SVH)JBT 847 | TR8)K4V 848 | MPD)7SR 849 | Y36)DP3 850 | LM2)K21 851 | KD1)2S1 852 | FC8)J3M 853 | JFD)BWF 854 | 6Y3)88F 855 | STT)GXN 856 | KKC)DW9 857 | 52L)B3G 858 | 5BK)XWX 859 | H6X)5BQ 860 | YH6)FGK 861 | VM3)6RN 862 | BWH)1PZ 863 | JK2)BCD 864 | 9QT)LTX 865 | 6WK)F5B 866 | HYC)C97 867 | GSP)3MR 868 | 6M3)B9P 869 | 7LD)9NZ 870 | N31)7KS 871 | GGG)9PB 872 | 6RM)SC1 873 | 83C)TGT 874 | BWT)1TJ 875 | 7YH)CN7 876 | JLD)PFT 877 | W95)JNX 878 | ZBT)Y2F 879 | TPD)RSK 880 | 3BS)BR6 881 | KG9)X9M 882 | 6HL)5D3 883 | WMN)P9S 884 | V32)V6H 885 | RYJ)3HM 886 | SF9)SBK 887 | HQ4)19C 888 | BWF)2W7 889 | 2LC)91R 890 | VCD)3G2 891 | VKJ)9BJ 892 | NL2)VKJ 893 | NLF)HY7 894 | BR6)L6V 895 | TQ4)8N9 896 | QH7)W84 897 | D6K)GGG 898 | W1J)SLM 899 | DB2)RQS 900 | M18)RRD 901 | DXS)32S 902 | KL8)YRT 903 | Q5W)VD4 904 | SCC)WQX 905 | GQW)VRT 906 | 52N)J47 907 | Z9M)6FX 908 | FKX)GSK 909 | TKX)WRS 910 | 7YH)NFG 911 | 9Y6)WZV 912 | 7BS)48W 913 | NT5)KSX 914 | 1Y8)RYV 915 | 814)J2F 916 | GSK)KRQ 917 | FBC)W1J 918 | C9G)VRY 919 | V2F)8TN 920 | 5M4)Y9S 921 | X9Q)T71 922 | Q7G)9HB 923 | YLR)4YM 924 | 18L)29D 925 | M1M)1BT 926 | 82F)MX3 927 | 9BJ)BBL 928 | R55)HRQ 929 | 9RH)R5S 930 | 414)MHV 931 | ML2)Y8T 932 | 179)7YH 933 | GK3)5Q9 934 | 7CZ)VRM 935 | QP3)LDF 936 | YRM)D92 937 | KXC)B8Y 938 | 2ZB)6X1 939 | XWX)JCF 940 | B3G)CG7 941 | LHT)4NT 942 | NNN)5LW 943 | 48W)R9S 944 | 91R)6J4 945 | 97T)BBF 946 | 1BT)KWW 947 | B53)QL9 948 | HBC)DB2 949 | 2D1)89S 950 | BBL)WBG 951 | 7WK)LJP 952 | TV1)SNJ 953 | K5Q)L9Q 954 | HNN)YKD 955 | BXP)W81 956 | 64N)GLG 957 | L9Q)M4Y 958 | PTB)8JP 959 | RHP)3FJ 960 | 657)PWZ 961 | HZ7)T8S 962 | YKD)W25 963 | PYL)SMP 964 | YSQ)HSJ 965 | W84)9F8 966 | HQS)NL2 967 | 3MC)6Y3 968 | 24K)MDD 969 | G3D)B17 970 | 2QF)PXH 971 | 38D)FNB 972 | 614)SVH 973 | 34H)BWT 974 | 6L3)GZD 975 | J1Y)QJ9 976 | 3XF)GG9 977 | MHQ)25V 978 | 3PQ)L4T 979 | 57T)3W4 980 | 8KQ)614 981 | PC9)P5K 982 | C2Q)F4P 983 | J37)FW2 984 | TDC)M1F 985 | YD4)LZV 986 | 4H5)HYC 987 | VRY)5XG 988 | 3W4)YLR 989 | JZ1)Q21 990 | SBK)1XQ 991 | RVK)6XT 992 | 9NS)LVG 993 | JBT)612 994 | J4R)QWT 995 | YDT)31V 996 | 123)C78 997 | PN3)PTM 998 | 6QM)5GN 999 | CG7)PF8 1000 | HX4)T4H 1001 | 6CK)HXR 1002 | PFT)H53 1003 | 62W)FC8 1004 | KQ6)4X5 1005 | 3CK)8Z5 1006 | RHS)Q7G 1007 | N13)2LT 1008 | D3J)NYJ 1009 | PFY)N44 1010 | N3F)4FF 1011 | P89)29Z 1012 | MHN)J49 1013 | S78)LCK 1014 | 8DD)DR5 1015 | 51H)VM3 1016 | 1NF)MLL 1017 | S99)RKK 1018 | 9PD)JLD 1019 | 7Q5)7WK 1020 | 7WK)MND 1021 | CQR)KG9 1022 | X5B)VTN 1023 | SCW)RPP 1024 | BF4)3XF 1025 | QL9)R8G 1026 | LDB)4X4 1027 | VDN)73Z 1028 | 9KY)BXN 1029 | VTN)WJ1 1030 | 8F4)PR2 1031 | F78)92J 1032 | 7SX)GQW 1033 | GR7)22P 1034 | 56B)7SX 1035 | 876)HPY 1036 | HNP)V7Y 1037 | SNJ)HHH 1038 | KNR)W7S 1039 | HT2)T9W 1040 | PC2)B9Y 1041 | 6VJ)HNP 1042 | 4TS)32D 1043 | 7FB)TZ5 1044 | 5BQ)PRT 1045 | PRT)97T 1046 | G44)9DX 1047 | THR)81Z 1048 | 25P)MCD 1049 | Z9L)R92 1050 | V1P)L1D 1051 | DSZ)TVC 1052 | VKV)TQ4 1053 | 4LM)YM4 1054 | T8S)6N6 1055 | HPP)WV4 1056 | 99X)8YW 1057 | B9P)HDV 1058 | T2Q)TNM 1059 | JVG)7XG 1060 | QGH)KTD 1061 | DBX)VNZ 1062 | DFM)RSW 1063 | 29D)GYC 1064 | LYS)38D 1065 | MKK)WXZ 1066 | 5B5)MQ5 1067 | BPX)2NW 1068 | 5LR)PYY 1069 | VXL)6HL --------------------------------------------------------------------------------