From 0d01bb3582b4b7f5ee86ff37a8136161c5c061c3 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Sun, 3 Dec 2017 11:13:08 +0000 Subject: [PATCH] Rearranged file locations --- adventofcode1701/Setup.hs => Setup.hs | 0 ...ntofcode1702.cabal => adventofcode17.cabal | 11 ++- adventofcode1701/README.md | 1 - adventofcode1701/adventofcode1701.cabal | 26 ----- adventofcode1701/src/Main.hs | 5 - adventofcode1702/README.md | 1 - adventofcode1702/Setup.hs | 2 - adventofcode1702/src/Main.hs | 5 - .../app => src/advent01}/advent01-Copy1.ipynb | 0 .../app => src/advent01}/advent01.hs | 0 .../app => src/advent01}/advent01.ipynb | 62 ++++++------ .../app => src/advent01}/advent01verbose.hs | 0 .../app => src/advent02}/advent02.hs | 0 .../app => src/advent02}/advent02.ipynb | 95 ++++++++++++------- stack.yaml | 2 - 15 files changed, 101 insertions(+), 109 deletions(-) rename adventofcode1701/Setup.hs => Setup.hs (100%) rename adventofcode1702/adventofcode1702.cabal => adventofcode17.cabal (72%) delete mode 100644 adventofcode1701/README.md delete mode 100644 adventofcode1701/adventofcode1701.cabal delete mode 100644 adventofcode1701/src/Main.hs delete mode 100644 adventofcode1702/README.md delete mode 100644 adventofcode1702/Setup.hs delete mode 100644 adventofcode1702/src/Main.hs rename {adventofcode1701/app => src/advent01}/advent01-Copy1.ipynb (100%) rename {adventofcode1701/app => src/advent01}/advent01.hs (100%) rename {adventofcode1701/app => src/advent01}/advent01.ipynb (92%) rename {adventofcode1701/app => src/advent01}/advent01verbose.hs (100%) rename {adventofcode1702/app => src/advent02}/advent02.hs (100%) rename {adventofcode1702/app => src/advent02}/advent02.ipynb (72%) diff --git a/adventofcode1701/Setup.hs b/Setup.hs similarity index 100% rename from adventofcode1701/Setup.hs rename to Setup.hs diff --git a/adventofcode1702/adventofcode1702.cabal b/adventofcode17.cabal similarity index 72% rename from adventofcode1702/adventofcode1702.cabal rename to adventofcode17.cabal index 994616e..0bb0202 100644 --- a/adventofcode1702/adventofcode1702.cabal +++ b/adventofcode17.cabal @@ -1,4 +1,4 @@ -name: adventofcode1702 +name: adventofcode17 version: 0.1.0.0 -- synopsis: -- description: @@ -18,8 +18,15 @@ library build-depends: base >= 4.7 && < 5 default-language: Haskell2010 +executable advent01 + hs-source-dirs: src/advent01 + main-is: advent01.hs + default-language: Haskell2010 + build-depends: base >= 4.7 && < 5 + , parsec + executable advent02 - hs-source-dirs: app + hs-source-dirs: src/advent02 main-is: advent02.hs default-language: Haskell2010 build-depends: base >= 4.7 && < 5 diff --git a/adventofcode1701/README.md b/adventofcode1701/README.md deleted file mode 100644 index 5c53720..0000000 --- a/adventofcode1701/README.md +++ /dev/null @@ -1 +0,0 @@ -# adventofcode1701 diff --git a/adventofcode1701/adventofcode1701.cabal b/adventofcode1701/adventofcode1701.cabal deleted file mode 100644 index f7c8fc6..0000000 --- a/adventofcode1701/adventofcode1701.cabal +++ /dev/null @@ -1,26 +0,0 @@ -name: adventofcode1701 -version: 0.1.0.0 --- synopsis: --- description: -homepage: https://github.com/neilnjae/advent-of-code-17#readme -license: BSD3 -license-file: LICENSE -author: Neil Smith -maintainer: noone@njae.me.uk -copyright: 2017 Neil Smith -category: None -build-type: Simple -cabal-version: >=1.10 -extra-source-files: README.md - -library - hs-source-dirs: src - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 - -executable advent01 - hs-source-dirs: app - main-is: advent01.hs - default-language: Haskell2010 - build-depends: base >= 4.7 && < 5 - , parsec \ No newline at end of file diff --git a/adventofcode1701/src/Main.hs b/adventofcode1701/src/Main.hs deleted file mode 100644 index 9cd992d..0000000 --- a/adventofcode1701/src/Main.hs +++ /dev/null @@ -1,5 +0,0 @@ -module Main where - -main :: IO () -main = do - putStrLn "hello world" diff --git a/adventofcode1702/README.md b/adventofcode1702/README.md deleted file mode 100644 index 5c53720..0000000 --- a/adventofcode1702/README.md +++ /dev/null @@ -1 +0,0 @@ -# adventofcode1701 diff --git a/adventofcode1702/Setup.hs b/adventofcode1702/Setup.hs deleted file mode 100644 index 9a994af..0000000 --- a/adventofcode1702/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/adventofcode1702/src/Main.hs b/adventofcode1702/src/Main.hs deleted file mode 100644 index 9cd992d..0000000 --- a/adventofcode1702/src/Main.hs +++ /dev/null @@ -1,5 +0,0 @@ -module Main where - -main :: IO () -main = do - putStrLn "hello world" diff --git a/adventofcode1701/app/advent01-Copy1.ipynb b/src/advent01/advent01-Copy1.ipynb similarity index 100% rename from adventofcode1701/app/advent01-Copy1.ipynb rename to src/advent01/advent01-Copy1.ipynb diff --git a/adventofcode1701/app/advent01.hs b/src/advent01/advent01.hs similarity index 100% rename from adventofcode1701/app/advent01.hs rename to src/advent01/advent01.hs diff --git a/adventofcode1701/app/advent01.ipynb b/src/advent01/advent01.ipynb similarity index 92% rename from adventofcode1701/app/advent01.ipynb rename to src/advent01/advent01.ipynb index cd6ab10..7452dff 100644 --- a/adventofcode1701/app/advent01.ipynb +++ b/src/advent01/advent01.ipynb @@ -21,7 +21,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -37,7 +37,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -49,7 +49,7 @@ }, { "cell_type": "code", - "execution_count": 80, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -59,7 +59,7 @@ }, { "cell_type": "code", - "execution_count": 86, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -69,7 +69,7 @@ }, { "cell_type": "code", - "execution_count": 87, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -88,7 +88,7 @@ }, { "cell_type": "code", - "execution_count": 88, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -107,7 +107,7 @@ }, { "cell_type": "code", - "execution_count": 89, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -126,7 +126,7 @@ }, { "cell_type": "code", - "execution_count": 90, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -145,30 +145,30 @@ }, { "cell_type": "code", - "execution_count": 91, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ - "part2 :: String -> Integer \n", - "part2 = sum_valid_pairs . part2_extract" + "part2_extract :: String -> [String]\n", + "part2_extract digits = map (\\ds -> (take 1 ds) ++ (take 1 $ drop offset ds)) \n", + " $ take (length digits) \n", + " $ tails (digits ++ digits)\n", + " where offset = length digits `div` 2" ] }, { "cell_type": "code", - "execution_count": 92, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ - "part2_extract :: String -> [String]\n", - "part2_extract digits = map (\\ds -> (take 1 ds) ++ (take 1 $ drop offset ds)) \n", - " $ take (length digits) \n", - " $ tails (digits ++ digits)\n", - " where offset = length digits `div` 2" + "part2 :: String -> Integer \n", + "part2 = sum_valid_pairs . part2_extract" ] }, { "cell_type": "code", - "execution_count": 93, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -187,7 +187,7 @@ }, { "cell_type": "code", - "execution_count": 94, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -206,7 +206,7 @@ }, { "cell_type": "code", - "execution_count": 95, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -225,7 +225,7 @@ }, { "cell_type": "code", - "execution_count": 96, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -244,7 +244,7 @@ }, { "cell_type": "code", - "execution_count": 97, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -263,7 +263,7 @@ }, { "cell_type": "code", - "execution_count": 98, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -282,7 +282,7 @@ }, { "cell_type": "code", - "execution_count": 99, + "execution_count": 19, "metadata": {}, "outputs": [ { @@ -301,7 +301,7 @@ }, { "cell_type": "code", - "execution_count": 100, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -320,7 +320,7 @@ }, { "cell_type": "code", - "execution_count": 70, + "execution_count": 21, "metadata": {}, "outputs": [ { @@ -339,7 +339,7 @@ }, { "cell_type": "code", - "execution_count": 77, + "execution_count": 22, "metadata": {}, "outputs": [ { @@ -358,7 +358,7 @@ }, { "cell_type": "code", - "execution_count": 71, + "execution_count": 23, "metadata": {}, "outputs": [ { @@ -377,7 +377,7 @@ }, { "cell_type": "code", - "execution_count": 78, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -396,7 +396,7 @@ }, { "cell_type": "code", - "execution_count": 101, + "execution_count": 25, "metadata": {}, "outputs": [], "source": [ @@ -409,7 +409,7 @@ }, { "cell_type": "code", - "execution_count": 102, + "execution_count": 26, "metadata": {}, "outputs": [ { diff --git a/adventofcode1701/app/advent01verbose.hs b/src/advent01/advent01verbose.hs similarity index 100% rename from adventofcode1701/app/advent01verbose.hs rename to src/advent01/advent01verbose.hs diff --git a/adventofcode1702/app/advent02.hs b/src/advent02/advent02.hs similarity index 100% rename from adventofcode1702/app/advent02.hs rename to src/advent02/advent02.hs diff --git a/adventofcode1702/app/advent02.ipynb b/src/advent02/advent02.ipynb similarity index 72% rename from adventofcode1702/app/advent02.ipynb rename to src/advent02/advent02.ipynb index 66a1ac9..490084b 100644 --- a/adventofcode1702/app/advent02.ipynb +++ b/src/advent02/advent02.ipynb @@ -12,7 +12,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -22,26 +22,26 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ - "sFile = sLine `sepEndBy` newline \n", - "sLine = int `sepBy` onlySpaces" + "onlySpaces = many (oneOf \" \\t\")" ] }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ - "onlySpaces = many (oneOf \" \\t\")" + "sFile = sLine `sepEndBy` newline \n", + "sLine = int `sepBy` onlySpaces" ] }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -58,7 +58,7 @@ }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -66,21 +66,20 @@ "main = do \n", " text <- readFile \"../../data/advent02.txt\"\n", " let sheet = successfulParse $ parseFile text\n", - "-- print sheet\n", - " print $ part1 sheet\n", - " print $ part2 sheet" + " print sheet\n", + "-- print $ part1 sheet\n", + "-- print $ part2 sheet" ] }, { "cell_type": "code", - "execution_count": 66, + "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "39126\n", - "258" + "[[179,2358,5197,867,163,4418,3135,5049,187,166,4682,5080,5541,172,4294,1397],[2637,136,3222,591,2593,1982,4506,195,4396,3741,2373,157,4533,3864,4159,142],[1049,1163,1128,193,1008,142,169,168,165,310,1054,104,1100,761,406,173],[200,53,222,227,218,51,188,45,98,194,189,42,50,105,46,176],[299,2521,216,2080,2068,2681,2376,220,1339,244,605,1598,2161,822,387,268],[1043,1409,637,1560,970,69,832,87,78,1391,1558,75,1643,655,1398,1193],[90,649,858,2496,1555,2618,2302,119,2675,131,1816,2356,2480,603,65,128],[2461,5099,168,4468,5371,2076,223,1178,194,5639,890,5575,1258,5591,6125,226],[204,205,2797,2452,2568,2777,1542,1586,241,836,3202,2495,197,2960,240,2880],[560,96,336,627,546,241,191,94,368,528,298,78,76,123,240,563],[818,973,1422,244,1263,200,1220,208,1143,627,609,274,130,961,685,1318],[1680,1174,1803,169,450,134,3799,161,2101,3675,133,4117,3574,4328,3630,4186],[1870,3494,837,115,1864,3626,24,116,2548,1225,3545,676,128,1869,3161,109],[890,53,778,68,65,784,261,682,563,781,360,382,790,313,785,71],[125,454,110,103,615,141,562,199,340,80,500,473,221,573,108,536],[1311,64,77,1328,1344,1248,1522,51,978,1535,1142,390,81,409,68,352]]" ] }, "metadata": {}, @@ -93,7 +92,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -112,7 +111,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -131,7 +130,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -150,7 +149,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -160,7 +159,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -170,7 +169,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -189,7 +188,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -198,7 +197,7 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -218,7 +217,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -237,14 +236,7 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 55, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -264,7 +256,7 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -283,7 +275,7 @@ }, { "cell_type": "code", - "execution_count": 61, + "execution_count": 19, "metadata": {}, "outputs": [], "source": [ @@ -292,13 +284,48 @@ }, { "cell_type": "code", - "execution_count": 64, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "part2 = sum . map p2cSum" ] }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [], + "source": [ + "main :: IO ()\n", + "main = do \n", + " text <- readFile \"../../data/advent02.txt\"\n", + " let sheet = successfulParse $ parseFile text\n", + "-- print sheet\n", + " print $ part1 sheet\n", + " print $ part2 sheet" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "39126\n", + "258" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "main" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/stack.yaml b/stack.yaml index 14cf15c..3bef45f 100644 --- a/stack.yaml +++ b/stack.yaml @@ -3,8 +3,6 @@ extra-package-dbs: [] ghc-options: ! '*': -O2 -Wall -Wno-missing-signatures -threaded -rtsopts -with-rtsopts=-N packages: -- adventofcode1701/ -- adventofcode1702/ extra-deps: - parsec-numbers-0.1.0 resolver: lts-9.14 -- 2.34.1