projects
/
advent-of-code-22.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
402a27d
)
Tidying
author
Neil Smith
<NeilNjae@users.noreply.github.com>
Tue, 27 Dec 2022 08:34:39 +0000
(08:34 +0000)
committer
Neil Smith
<NeilNjae@users.noreply.github.com>
Tue, 27 Dec 2022 08:34:39 +0000
(08:34 +0000)
advent17/Main.hs
patch
|
blob
|
history
advent19/Main.hs
patch
|
blob
|
history
advent20/Main.hs
patch
|
blob
|
history
advent21/Main.hs
patch
|
blob
|
history
advent22/Main.hs
patch
|
blob
|
history
advent25/Main.hs
patch
|
blob
|
history
diff --git
a/advent17/Main.hs
b/advent17/Main.hs
index 57794a95591b8c564b3d7e716fbe29c89ad1ef4b..ce3ad424086b550569c9f788c7dcd52db018307d 100644
(file)
--- a/
advent17/Main.hs
+++ b/
advent17/Main.hs
@@
-4,7
+4,6
@@
import AoC
import qualified Data.Set as S
import AoC
import qualified Data.Set as S
-import qualified Data.Map.Strict as M
import Linear hiding (Trace, trace, distance)
import Control.Lens
import Data.Maybe
import Linear hiding (Trace, trace, distance)
import Control.Lens
import Data.Maybe
diff --git
a/advent19/Main.hs
b/advent19/Main.hs
index b5cd5c4457051fc4c7b43441ceb645e8eda62aa5..7fe03159c679cabf2c5a6244cbcb3d8130d52ed0 100644
(file)
--- a/
advent19/Main.hs
+++ b/
advent19/Main.hs
@@
-1,6
+1,6
@@
-- Writeup at https://work.njae.me.uk/2022/12/21/advent-of-code-2022-day-19/
-- Writeup at https://work.njae.me.uk/2022/12/21/advent-of-code-2022-day-19/
-import Debug.Trace
+
--
import Debug.Trace
import AoC
import Data.Text (Text)
import AoC
import Data.Text (Text)
@@
-16,7
+16,7
@@
import Data.MultiSet as MS
import Data.Sequence ((|>))
import Data.List
import Data.Maybe
import Data.Sequence ((|>))
import Data.List
import Data.Maybe
-import Data.Ord
+
--
import Data.Ord
import Control.Monad.Reader
import Control.Lens hiding ((<|), (|>), (:>), (:<), indices)
import Control.Parallel.Strategies
import Control.Monad.Reader
import Control.Lens hiding ((<|), (|>), (:>), (:<), indices)
import Control.Parallel.Strategies
diff --git
a/advent20/Main.hs
b/advent20/Main.hs
index eb60a158b15bd9b034c571b69f1ef6beb1ae5999..355d949ff56e9c144b931975f9ea40281e4d796d 100644
(file)
--- a/
advent20/Main.hs
+++ b/
advent20/Main.hs
@@
-1,10
+1,10
@@
-- Writeup at https://work.njae.me.uk/2022/12/21/advent-of-code-2022-day-20/
import AoC
-- Writeup at https://work.njae.me.uk/2022/12/21/advent-of-code-2022-day-20/
import AoC
-import Data.List
+import Data.List
hiding (elemIndex)
import Data.Maybe
import Data.CircularList
import Data.Maybe
import Data.CircularList
-import Control.Lens
+import Control.Lens
hiding (element)
data IndexedElem = IndexedElem { _idx :: Int, _shift :: Int, _value :: Int}
deriving (Show, Eq, Ord)
data IndexedElem = IndexedElem { _idx :: Int, _shift :: Int, _value :: Int}
deriving (Show, Eq, Ord)
diff --git
a/advent21/Main.hs
b/advent21/Main.hs
index 181161227c5f731e2bc0e691efb2cadb0b7a8f27..6d856e54b6ee9bfc358fb783857bea51b3cc54f5 100644
(file)
--- a/
advent21/Main.hs
+++ b/
advent21/Main.hs
@@
-7,7
+7,7
@@
import Data.Attoparsec.Text hiding (take, D)
import Control.Applicative
import qualified Data.Map.Strict as M
import Data.Map.Strict ((!))
import Control.Applicative
import qualified Data.Map.Strict as M
import Data.Map.Strict ((!))
-import Control.Lens
+import Control.Lens
hiding (op)
data Shout = Literal Int | Operation Operator String String
deriving (Show, Eq, Ord)
data Shout = Literal Int | Operation Operator String String
deriving (Show, Eq, Ord)
diff --git
a/advent22/Main.hs
b/advent22/Main.hs
index 1a2e1c7eb67281b52f3c35f3a3564f77ca5d2bb3..848be83e062923f8148bd79046cfc307411d884f 100644
(file)
--- a/
advent22/Main.hs
+++ b/
advent22/Main.hs
@@
-2,6
+2,7
@@
-- import Debug.Trace
-- import Debug.Trace
+
import AoC
import Prelude hiding (Left, Right)
import qualified Data.Map.Strict as M
import AoC
import Prelude hiding (Left, Right)
import qualified Data.Map.Strict as M
@@
-253,13
+254,16
@@
isCell r c rows = isRow && isCol && ((rows !! r) !! c) `elem` (".#" :: String)
where isRow = r < length rows
isCol = c < (length $ rows !! r)
where isRow = r < length rows
isCol = c < (length $ rows !! r)
-mkInstructions :: String -> [PathElement]
+mkInstructions
, mkWalk, mkTurn
:: String -> [PathElement]
mkInstructions [] = []
mkInstructions [] = []
-mkInstructions text@(t:
ts
)
+mkInstructions text@(t:
_
)
| isDigit t = mkWalk text
| otherwise = mkTurn text
| isDigit t = mkWalk text
| otherwise = mkTurn text
+
mkWalk text = (Forward $ read digits) : (mkInstructions remainder)
where (digits, remainder) = span (isDigit) text
mkWalk text = (Forward $ read digits) : (mkInstructions remainder)
where (digits, remainder) = span (isDigit) text
+
+mkTurn [] = []
mkTurn (t:ts)
| t == 'R' = Clockwise : (mkInstructions ts)
| t == 'L' = Anticlockwise : (mkInstructions ts)
mkTurn (t:ts)
| t == 'R' = Clockwise : (mkInstructions ts)
| t == 'L' = Anticlockwise : (mkInstructions ts)
diff --git
a/advent25/Main.hs
b/advent25/Main.hs
index 28c33f751f4afc874e952d4b29371472782536f9..c58c47dc015da9bcd9e060d6eb1d885a2882c1db 100644
(file)
--- a/
advent25/Main.hs
+++ b/
advent25/Main.hs
@@
-35,7
+35,7
@@
packSnafu :: [Int] -> String
packSnafu digits
| carry == 0 = shown
| otherwise = (snafuRep carry) : shown
packSnafu digits
| carry == 0 = shown
| otherwise = (snafuRep carry) : shown
- where (carry, shown) = foldl' packSnafuDigit (0, "")
+ where (carry, shown) = foldl' packSnafuDigit (0, "")
digits
packSnafuDigit :: (Int, String) -> Int -> (Int, String)
packSnafuDigit (carry, acc) d
packSnafuDigit :: (Int, String) -> Int -> (Int, String)
packSnafuDigit (carry, acc) d