Day 11
authorNeil Smith <neil.git@njae.me.uk>
Mon, 11 Dec 2017 09:59:20 +0000 (09:59 +0000)
committerNeil Smith <neil.git@njae.me.uk>
Mon, 11 Dec 2017 09:59:20 +0000 (09:59 +0000)
advent-of-code.cabal
data/advent11.txt [new file with mode: 0644]
src/advent11/advent11.hs [new file with mode: 0644]
src/advent11/advent11.ipynb [new file with mode: 0644]

index 3ad97bd6a65e5574fe3e88962d7374560d02d86a..a88c6a0e3cb150bda279b9fe4e1b792286da3e0d 100644 (file)
@@ -101,3 +101,10 @@ executable advent10
   default-language:    Haskell2010
   build-depends:       base >= 4.7 && < 5
                      , split
+
+executable advent11
+  hs-source-dirs:      src/advent11
+  main-is:             advent11.hs
+  default-language:    Haskell2010
+  build-depends:       base >= 4.7 && < 5
+                     , split
diff --git a/data/advent11.txt b/data/advent11.txt
new file mode 100644 (file)
index 0000000..55459f5
--- /dev/null
@@ -0,0 +1 @@
+ne,nw,se,nw,ne,s,s,s,sw,ne,sw,sw,sw,sw,sw,nw,nw,sw,se,ne,nw,nw,nw,nw,nw,nw,n,n,s,nw,n,n,nw,n,n,n,n,ne,n,n,ne,n,n,s,n,se,ne,ne,ne,n,se,ne,ne,ne,ne,se,ne,ne,ne,ne,ne,ne,ne,sw,ne,ne,s,se,se,se,s,ne,ne,se,ne,ne,sw,ne,se,se,se,se,se,se,s,s,se,se,ne,se,se,se,se,ne,se,se,s,se,se,s,n,s,se,s,ne,se,se,nw,ne,s,n,s,se,se,s,se,se,se,s,sw,se,s,s,s,n,se,se,s,se,s,se,se,s,se,se,s,s,ne,s,s,se,n,s,s,s,s,sw,s,s,n,s,sw,n,s,s,s,s,s,sw,s,s,s,s,s,sw,s,se,ne,s,s,s,s,s,sw,s,sw,s,nw,sw,s,s,sw,sw,nw,s,sw,se,sw,sw,sw,s,se,s,sw,se,nw,sw,s,n,s,sw,n,sw,n,sw,sw,sw,nw,nw,sw,sw,sw,s,sw,s,sw,sw,sw,sw,sw,sw,sw,se,n,nw,s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w,nw,ne,ne,ne,ne,n,sw,se,ne,ne,ne,ne,ne,ne,ne,n,n,sw,ne,ne,se,n,ne,sw,ne,ne,ne,n,ne,ne,ne,ne,sw,ne,ne,ne,ne,sw,ne,ne,ne,ne,ne,nw,ne,ne,ne,ne,ne,ne,nw,ne,ne,se,ne,ne,se,ne,ne,ne,ne,ne,ne,s,se,s,ne,ne,ne,n,ne,ne,n,ne,ne,ne,nw,ne,s,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,se,ne,ne,ne,ne,ne,se,ne,ne,s,s,nw,ne,ne,ne,se,ne,s,n,se,n,ne,ne,s,se,se,se,ne,ne,ne,se,sw,se,ne,ne,nw,ne,se,ne,ne,ne,ne,se,ne,nw,ne,ne,ne,se,ne,se,s,se,se,ne,ne,ne,ne,ne,s,ne,ne,ne,ne,ne,ne,ne,ne,nw,ne,ne,se,sw,ne,se,ne,nw,se,n,se,n,ne,ne,ne,ne,s,se,ne,se,se,ne,ne,ne,ne,ne,se,ne,se,ne,se,ne,se,se,se,ne,nw,ne,nw,ne,ne,se,s,ne,s,n,se,sw,ne,se,ne,ne,ne,se,se,ne,ne,se,se,se,se,ne,n,sw,ne,se,ne,sw,sw,nw,s,se,se,ne,se,n,ne,se,s,sw,ne,se,se,s,se,se,se,se,se,sw,ne,se,s,se,se,s,se,ne,se,ne,ne,se,ne,se,ne,se,se,ne,ne,ne,se,ne,se,n,se,se,se,s,ne,se,se,ne,s,s,nw,ne,se,se,ne,se,se,se,se,se,se,se,s,se,se,sw,se,sw,se,se,se,ne,se,s,se,se,se,se,se,se,se,se,ne,se,s,se,se,se,se,sw,n,se,se,se,ne,se,se,se,se,s,se,se,sw,se,se,se,sw,se,n,se,se,se,se,se,nw,se,se,sw,se,se,s,se,se,se,ne,se,se,se,se,s,se,se,se,se,s,se,se,se,s,se,se,s,se,se,se,se,se,se,se,se,se,se,n,se,s,se,se,se,se,se,ne,se,se,se,ne,se,se,se,se,n,se,se,se,se,se,se,se,se,se,se,s,s,se,ne,s,se,s,se,s,se,se,s,s,s,se,s,se,se,ne,s,s,se,se,se,s,s,se,se,se,s,se,se,ne,s,n,s,s,se,ne,se,se,sw,se,se,se,se,s,n,s,s,sw,sw,se,s,se,ne,se,se,se,s,se,n,s,s,sw,se,se,se,s,se,se,s,sw,s,s,se,se,nw,s,s,se,nw,n,s,se,s,se,se,sw,s,s,se,se,s,se,n,nw,se,se,s,s,s,se,s,s,se,s,se,se,s,n,s,se,s,se,s,sw,nw,ne,s,s,se,se,se,se,s,se,se,s,s,s,se,se,se,sw,se,se,n,se,se,n,s,se,se,s,s,se,ne,sw,se,se,s,se,s,s,se,se,s,se,se,s,s,nw,se,se,s,se,n,s,n,n,se,s,se,se,se,sw,s,s,n,s,s,se,ne,se,nw,se,s,s,s,s,s,se,ne,s,se,s,se,n,sw,nw,s,s,s,s,nw,se,sw,se,s,s,sw,s,nw,se,nw,s,s,nw,n,s,sw,se,s,nw,s,se,se,n,ne,s,s,s,s,se,s,se,s,se,s,s,s,se,s,s,s,sw,s,s,s,se,s,s,s,s,se,s,s,s,ne,se,s,se,s,s,s,se,n,s,se,se,s,se,ne,s,n,s,s,se,ne,s,s,s,s,s,s,s,s,s,s,s,s,s,nw,se,s,n,se,s,se,s,ne,s,s,s,ne,n,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,se,s,s,n,s,n,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,n,s,s,s,s,s,s,s,s,s,sw,s,nw,sw,s,nw,s,s,s,nw,s,se,nw,s,s,s,s,s,s,sw,s,s,nw,s,sw,s,s,sw,s,s,s,s,ne,s,s,s,sw,sw,s,sw,s,s,s,s,se,s,s,sw,sw,s,s,s,s,s,n,nw,s,s,s,ne,s,n,s,s,sw,s,s,s,s,s,s,n,s,s,ne,s,ne,sw,s,ne,sw,s,s,ne,s,s,s,s,s,sw,s,s,s,s,sw,sw,sw,sw,s,se,sw,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se,ne,sw,sw,ne,ne,ne,ne,ne,s,ne,ne,n,ne,ne,nw,ne,n,se,n,n,ne,ne,ne,ne,nw,n,n,ne,n,n,n,n,n,n,nw,n,n,s,n,n,s,n,nw,n,ne,n,n,n,n,ne,nw,ne,n,nw,nw,nw,n,n,nw,nw,nw,nw,nw,nw,n,nw,nw,sw,sw,nw,nw,nw,nw,nw,nw,nw,sw,nw,nw,nw,nw,n,sw,nw,n,nw,nw,sw,sw,sw,nw,sw,nw,sw,sw,sw,sw,ne,nw,sw,s,n,sw,sw,nw,nw,n,se,sw,s,sw,se,s,nw,nw,sw,se,sw,sw,sw,nw,sw,sw,sw,sw,sw,sw,sw,sw,sw,nw,sw,s,sw,n,sw,se,s,sw,sw,sw,s,s,sw,s,sw,ne,sw,s,sw,s,sw,s,s,s,nw,s,s,s,sw,s,sw,s,s,ne,s,s,s,s,sw,s,ne,s,n,sw,s,s,s,s,s,se,n,s,s,s,s,n,n,s,nw,se,s,s,s,se,sw,s,ne,se,n,s,s,s,s,s,n,se,s,se,s,se,s,se,n,se,sw,sw,s,se,s,s,s,s,sw,s,s,s,se,se,s,s,se,se,s,se,n,s,n,s,se,se,n,s,sw,s,ne,se,sw,se,se,n,s,s,se,nw,se,s,s,n,se,se,se,se,se,se,s,s,nw,se,s,se,se,se,se,se,se,s,s,s,se,ne,n,se,s,se,se,s,s,sw,se,se,nw,sw,se,se,se,se,ne,se,se,sw,se,sw,s,sw,n,se,se,se,se,se,ne,se,se,se,se,se,se,se,ne,se,se,se,s,ne,se,n,ne,sw,ne,ne,se,nw,se,sw,se,se,ne,n,se,se,se,ne,se,se,s,ne,ne,nw,se,se,n,se,se,sw,ne,se,ne,se,se,ne,se,se,nw,ne,ne,se,ne,n,ne,ne,se,ne,ne,ne,ne,ne,ne,se,se,ne,se,ne,se,se,ne,ne,se,s,ne,ne,ne,ne,ne,ne,s,ne,ne,se,se,ne,ne,se,ne,ne,ne,se,se,se,se,ne,ne,ne,ne,ne,ne,se,nw,ne,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s,s,s,se,nw,s,s,se,nw,s,sw,s,se,s,s,s,s,s,s,s,n,s,se,ne,se,se,s,s,s,s,se,s,s,se,se,s,s,s,se,sw,s,s,s,sw,se,s,s,nw,ne,n,nw,nw,se,s,s,se,s,s,ne,s,s,n,s,s,n,s,s,sw,s,s,s,s,s,ne,se,s,sw,nw,s,s,s,sw,n,ne,nw,s,se,ne,s,s,s,ne,se,s,n,nw,s,s,s,s,s,s,s,s,s,se,se,sw,s,s,s,s,se,se,s,n,s,s,s,s,s,s,se,se,s,s,s,se,se,se,s,ne,s,s,s,nw,s,sw,s,s,s,nw,s,nw,s,s,se,s,s,s,s,ne,s,s,s,s,s,sw,n,s,s,s,s,se,se,s,s,n,s,nw,sw,se,s,s,se,nw,s,s,s,se,sw,se,s,s,s,s,se,se,s,s,s,s,nw,se,se,s,se,ne,s,s,se,s,se,s,sw,sw,s,s,s,s,s,se,s,se,se,se,s,ne,s,nw,s,se,se,nw,s,s,ne,s,s,s,s,sw,s,n,s,s,s,s,sw,se,s,s,nw,s,ne,se,se,s,s,s,se,s,s,s,se,sw,se,n,sw,sw,se,s,s,s,s,s,s,s,s,ne,se,nw,sw,ne,s,s,s,s,sw,nw,se,s,n,nw,se,se,se,s,s,s,se,s,se,se,s,se,s,se,se,sw,nw,se,se,s,se,s,se,nw,ne,s,se,s,se,sw,s,s,se,s,n,nw,s,se,s,ne,sw,s,s,s,n,se,s,se,s,sw,se,s,sw,se,s,s,se,se,se,s,sw,se,se,s,s,s,s,n,se,s,se,nw,nw,s,se,s,s,s,se,s,se,ne,se,s,se,se,se,se,sw,se,se,se,se,se,se,n,s,se,se,n,nw,s,s,s,s,nw,se,s,s,se,s,s,nw,sw,se,s,s,s,se,se,s,se,s,se,s,sw,se,se,s,s,se,se,se,ne,n,s,s,se,se,se,se,s,s,se,se,s,se,s,s,se,sw,se,s,se,se,s,sw,se,s,sw,sw,se,s,s,s,se,sw,s,se,se,se,se,sw,se,s,s,se,se,s,s,s,s,ne,ne,s,s,se,se,se,s,se,se,se,se,se,se,s,se,se,se,n,se,se,s,se,sw,se,se,se,ne,se,se,se,se,se,nw,se,se,se,se,se,se,s,nw,se,se,se,s,se,se,s,se,s,s,ne,sw,se,se,se,s,s,se,se,s,se,se,s,se,n,se,se,s,s,se,se,ne,se,se,n,n,ne,s,se,se,s,n,s,sw,n,se,s,se,se,se,se,s,n,se,se,se,se,s,se,se,se,nw,se,se,s,se,se,se,se,sw,ne,s,se,s,se,se,se,se,n,se,se,se,se,se,se,se,se,se,se,se,se,se,se,sw,sw,se,se,se,nw,s,nw,se,se,se,se,se,se,s,s,se,se,nw,se,se,nw,nw,se,se,s,se,sw,se,se,se,se,n,ne,se,s,se,se,se,se,se,se,se,se,sw,s,se,se,sw,se,se,se,se,se,se,se,se,se,se,s,se,se,se,ne,nw,s,se,se,se,se,ne,se,s,se,se,se,se,se,se,nw,se,s,se,se,se,se,s,se,se,n,se,se,se,sw,se,sw,se,se,n,se,se,se,s,se,se,sw,ne,sw,s,se,se,se,se,sw,se,s,se,se,se,se,se,s,se,se,se,se,nw,ne,nw,se,se,n,se
\ No newline at end of file
diff --git a/src/advent11/advent11.hs b/src/advent11/advent11.hs
new file mode 100644 (file)
index 0000000..dd2bd9e
--- /dev/null
@@ -0,0 +1,36 @@
+import Data.List.Split (splitOn)
+
+main :: IO ()
+main = do 
+        text <- readFile "data/advent11.txt"
+        print $ part1 text
+        print $ part2 text
+
+part1 :: String -> Int
+part1 = distance . hexPath . splitOn ","
+
+part2 :: String -> Int
+part2 = maximum . map distance . hexPathB . splitOn ","
+
+hexStep :: (Int, Int) -> String -> (Int, Int)
+hexStep (n, ne) s = case s of 
+                        "n"  -> (n + 1, ne)
+                        "ne" -> (n,     ne + 1)
+                        "nw" -> (n + 1, ne - 1)
+                        "s"  -> (n - 1, ne)
+                        "se" -> (n - 1, ne + 1)
+                        "sw" -> (n,     ne - 1)
+                        _    -> (n,     ne)
+
+hexPath :: [String] -> (Int, Int)
+hexPath  = foldl hexStep (0, 0)
+
+hexPathB :: [String] -> [(Int, Int)]
+hexPathB = scanl hexStep (0, 0)
+
+distance :: (Int, Int) -> Int
+distance (n, ne) = if n * ne > 0 
+                   then (abs n) + (abs ne)
+                   else smallest + remainder
+                   where smallest = min (abs n) (abs ne)
+                         remainder = max ((abs n) - smallest) ((abs ne) - smallest)
diff --git a/src/advent11/advent11.ipynb b/src/advent11/advent11.ipynb
new file mode 100644 (file)
index 0000000..6d40bf5
--- /dev/null
@@ -0,0 +1,520 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "{-# LANGUAGE NegativeLiterals #-}\n",
+    "{-# LANGUAGE FlexibleContexts #-}"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "import Data.List.Split (splitOn)\n",
+    "import Data.List (mapAccumL)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 4,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "hexStep (Int, Int) -> String -> (Int, Int)\n",
+    "hexStep (n, ne) s = case s of \n",
+    "                        \"n\" -> (n + 1, ne)\n",
+    "                        \"ne\" -> (n, ne + 1)\n",
+    "                        \"nw\" -> (n + 1, ne - 1)\n",
+    "                        \"s\" -> (n - 1, ne)\n",
+    "                        \"se\" -> (n - 1, ne + 1)\n",
+    "                        \"sw\" -> (n, ne - 1)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 8,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "(4,[1,3,5,7])"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "mapAccumL (\\a b -> (a + 1, a + b))  0 [1,2,3,4]"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 23,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "hexPath = foldl hexStep (0, 0)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 24,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "3"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "distance $ hexPath $ splitOn \",\" \"ne,ne,ne\""
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 25,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "0"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "distance $ hexPath $ splitOn \",\" \"ne,ne,sw,sw\""
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 26,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "2"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "distance $ hexPath $ splitOn \",\" \"ne,ne,s,s\""
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 27,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "3"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "distance $ hexPath $ splitOn \",\" \"se,sw,se,sw,sw\""
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 28,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/html": [
+       "<style>/* Styles used for the Hoogle display in the pager */\n",
+       ".hoogle-doc {\n",
+       "display: block;\n",
+       "padding-bottom: 1.3em;\n",
+       "padding-left: 0.4em;\n",
+       "}\n",
+       ".hoogle-code {\n",
+       "display: block;\n",
+       "font-family: monospace;\n",
+       "white-space: pre;\n",
+       "}\n",
+       ".hoogle-text {\n",
+       "display: block;\n",
+       "}\n",
+       ".hoogle-name {\n",
+       "color: green;\n",
+       "font-weight: bold;\n",
+       "}\n",
+       ".hoogle-head {\n",
+       "font-weight: bold;\n",
+       "}\n",
+       ".hoogle-sub {\n",
+       "display: block;\n",
+       "margin-left: 0.4em;\n",
+       "}\n",
+       ".hoogle-package {\n",
+       "font-weight: bold;\n",
+       "font-style: italic;\n",
+       "}\n",
+       ".hoogle-module {\n",
+       "font-weight: bold;\n",
+       "}\n",
+       ".hoogle-class {\n",
+       "font-weight: bold;\n",
+       "}\n",
+       ".get-type {\n",
+       "color: green;\n",
+       "font-weight: bold;\n",
+       "font-family: monospace;\n",
+       "display: block;\n",
+       "white-space: pre-wrap;\n",
+       "}\n",
+       ".show-type {\n",
+       "color: green;\n",
+       "font-weight: bold;\n",
+       "font-family: monospace;\n",
+       "margin-left: 1em;\n",
+       "}\n",
+       ".mono {\n",
+       "font-family: monospace;\n",
+       "display: block;\n",
+       "}\n",
+       ".err-msg {\n",
+       "color: red;\n",
+       "font-style: italic;\n",
+       "font-family: monospace;\n",
+       "white-space: pre;\n",
+       "display: block;\n",
+       "}\n",
+       "#unshowable {\n",
+       "color: red;\n",
+       "font-weight: bold;\n",
+       "}\n",
+       ".err-msg.in.collapse {\n",
+       "padding-top: 0.7em;\n",
+       "}\n",
+       ".highlight-code {\n",
+       "white-space: pre;\n",
+       "font-family: monospace;\n",
+       "}\n",
+       ".suggestion-warning { \n",
+       "font-weight: bold;\n",
+       "color: rgb(200, 130, 0);\n",
+       "}\n",
+       ".suggestion-error { \n",
+       "font-weight: bold;\n",
+       "color: red;\n",
+       "}\n",
+       ".suggestion-name {\n",
+       "font-weight: bold;\n",
+       "}\n",
+       "</style><div class=\"suggestion-name\" style=\"clear:both;\">Redundant bracket</div><div class=\"suggestion-row\" style=\"float: left;\"><div class=\"suggestion-warning\">Found:</div><div class=\"highlight-code\" id=\"haskell\">(abs n) + (abs ne)</div></div><div class=\"suggestion-row\" style=\"float: left;\"><div class=\"suggestion-warning\">Why Not:</div><div class=\"highlight-code\" id=\"haskell\">abs n + (abs ne)</div></div><div class=\"suggestion-name\" style=\"clear:both;\">Redundant bracket</div><div class=\"suggestion-row\" style=\"float: left;\"><div class=\"suggestion-warning\">Found:</div><div class=\"highlight-code\" id=\"haskell\">(abs n) + (abs ne)</div></div><div class=\"suggestion-row\" style=\"float: left;\"><div class=\"suggestion-warning\">Why Not:</div><div class=\"highlight-code\" id=\"haskell\">(abs n) + abs ne</div></div><div class=\"suggestion-name\" style=\"clear:both;\">Redundant bracket</div><div class=\"suggestion-row\" style=\"float: left;\"><div class=\"suggestion-warning\">Found:</div><div class=\"highlight-code\" id=\"haskell\">(abs n) - smallest</div></div><div class=\"suggestion-row\" style=\"float: left;\"><div class=\"suggestion-warning\">Why Not:</div><div class=\"highlight-code\" id=\"haskell\">abs n - smallest</div></div><div class=\"suggestion-name\" style=\"clear:both;\">Redundant bracket</div><div class=\"suggestion-row\" style=\"float: left;\"><div class=\"suggestion-warning\">Found:</div><div class=\"highlight-code\" id=\"haskell\">(abs ne) - smallest</div></div><div class=\"suggestion-row\" style=\"float: left;\"><div class=\"suggestion-warning\">Why Not:</div><div class=\"highlight-code\" id=\"haskell\">abs ne - smallest</div></div>"
+      ],
+      "text/plain": [
+       "Line 2: Redundant bracket\n",
+       "Found:\n",
+       "(abs n) + (abs ne)\n",
+       "Why not:\n",
+       "abs n + (abs ne)Line 2: Redundant bracket\n",
+       "Found:\n",
+       "(abs n) + (abs ne)\n",
+       "Why not:\n",
+       "(abs n) + abs neLine 5: Redundant bracket\n",
+       "Found:\n",
+       "(abs n) - smallest\n",
+       "Why not:\n",
+       "abs n - smallestLine 5: Redundant bracket\n",
+       "Found:\n",
+       "(abs ne) - smallest\n",
+       "Why not:\n",
+       "abs ne - smallest"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "distance (n, ne) = if n * ne > 0 \n",
+    "                   then (abs n) + (abs ne)\n",
+    "                   else smallest + remainder\n",
+    "                   where smallest = min (abs n) (abs ne)\n",
+    "                         remainder = max ((abs n) - smallest) ((abs ne) - smallest)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 29,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "part1 = distance . hexPath . splitOn \",\""
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 30,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "main :: IO ()\n",
+    "main = do \n",
+    "        text <- readFile \"../../data/advent11.txt\"\n",
+    "--         let instrs = map read $ splitOn \",\" text\n",
+    "        print $ part1 text\n",
+    "--         print $ part2 text"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 31,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "670"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "main"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 32,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "hexPathB = scanl hexStep (0, 0)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 36,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "3"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "maximum $ map distance $ hexPathB $ splitOn \",\" \"ne,ne,ne\""
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 37,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[(0,0),(0,1),(0,2),(0,3)]"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "hexPathB $ splitOn \",\" \"ne,ne,ne\""
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 38,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[0,1,2,3]"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "map distance $ hexPathB $ splitOn \",\" \"ne,ne,ne\""
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 39,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "([(0,0),(0,1),(0,2),(0,3)],[0,1,2,3],3)"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "pth = splitOn \",\" \"ne,ne,ne\"\n",
+    "(hexPathB pth, map distance $ hexPathB pth, maximum $ map distance $ hexPathB pth)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 40,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "([(0,0),(0,1),(0,2),(0,1),(0,0)],[0,1,2,1,0],2)"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "pth = splitOn \",\" \"ne,ne,sw,sw\"\n",
+    "(hexPathB pth, map distance $ hexPathB pth, maximum $ map distance $ hexPathB pth)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 41,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "([(0,0),(0,1),(0,2),(-1,2),(-2,2)],[0,1,2,2,2],2)"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "pth = splitOn \",\" \"ne,ne,s,s\"\n",
+    "(hexPathB pth, map distance $ hexPathB pth, maximum $ map distance $ hexPathB pth)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 42,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "([(0,0),(-1,1),(-1,0),(-2,1),(-2,0),(-2,-1)],[0,1,1,2,2,3],3)"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "pth = splitOn \",\" \"se,sw,se,sw,sw\"\n",
+    "(hexPathB pth, map distance $ hexPathB pth, maximum $ map distance $ hexPathB pth)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 43,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "part2 = maximum . map distance . hexPathB . splitOn \",\""
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 44,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "main :: IO ()\n",
+    "main = do \n",
+    "        text <- readFile \"../../data/advent11.txt\"\n",
+    "--         let instrs = map read $ splitOn \",\" text\n",
+    "        print $ part1 text\n",
+    "        print $ part2 text"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 45,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "670\n",
+       "1426"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "main"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Haskell",
+   "language": "haskell",
+   "name": "haskell"
+  },
+  "language_info": {
+   "codemirror_mode": "ihaskell",
+   "file_extension": ".hs",
+   "name": "haskell",
+   "version": "8.0.2"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}