From 42fed81078c6babc676774a0c2816d49209f7953 Mon Sep 17 00:00:00 2001
From: Neil Smith <neil.git@njae.me.uk>
Date: Thu, 15 Dec 2016 11:05:06 +0000
Subject: [PATCH] Renamed the versions

---
 advent15.hs                  | 23 ++++++++++++++---------
 advent15f.hs => advent15l.hs | 23 +++++++++--------------
 2 files changed, 23 insertions(+), 23 deletions(-)
 rename advent15f.hs => advent15l.hs (59%)

diff --git a/advent15.hs b/advent15.hs
index e3c97fb..31866c0 100644
--- a/advent15.hs
+++ b/advent15.hs
@@ -1,6 +1,8 @@
 import Text.Parsec 
 import Text.ParserCombinators.Parsec.Number
 
+type Disk = (Int -> Bool)
+
 main :: IO ()
 main = do 
     text <- readFile "advent15.txt" 
@@ -8,15 +10,16 @@ main = do
     part1 disks
     part2 disks
 
-part1 :: [[Int]] -> IO ()
+part1 :: [Disk] -> IO ()
 part1 disks = print $ head $ filter (canFall disks) [0..]
 
-part2 :: [[Int]] -> IO ()
-part2 disks = print $ head $ filter (canFall disks2) [0..5000000]
-    where disks2 = id $! map (take 5000000) $ disks ++ [drop 7 $ drop 0 $ cycle [0..(11-1)]]
+part2 :: [Disk] -> IO ()
+part2 disks = print $ head $ filter (canFall disks2) [0..]
+    -- where disks2 = disks ++ [(\i -> (11 + 7 + 0 + i) `mod` 11 == 0)]
+    where disks2 = disks ++ [diskify 7 11 0]
 
-canFall :: [[Int]] -> Int -> Bool
-canFall ds i = all (\d -> (d!!i) == 0) ds
+canFall :: [Disk] -> Int -> Bool
+canFall ds i = all (\d -> (d i)) ds
 
 
 instructionFile = instructionLine `endBy` newline 
@@ -24,12 +27,14 @@ instructionLine = diskify <$> (string "Disc #" *> int)
                           <*> (string " has " *> int)
                           <*> (string " positions; at time=0, it is at position " *> int)
                           <*  (string ".")
-                    where diskify n size pos0 = drop n $ drop pos0 $ cycle [0..(size-1)]
 
-parseIfile :: String -> Either ParseError [[Int]]
+diskify :: Int -> Int -> Int -> (Int -> Bool)
+diskify n size pos0 = (\i -> (size + n + pos0 + i) `mod` size == 0)
+
+parseIfile :: String -> Either ParseError [Disk]
 parseIfile input = parse instructionFile "(unknown)" input
 
-parseIline :: String -> Either ParseError [Int]
+parseIline :: String -> Either ParseError Disk
 parseIline input = parse instructionLine "(unknown)" input
 
 successfulParse :: Either ParseError [a] -> [a]
diff --git a/advent15f.hs b/advent15l.hs
similarity index 59%
rename from advent15f.hs
rename to advent15l.hs
index 31866c0..e3c97fb 100644
--- a/advent15f.hs
+++ b/advent15l.hs
@@ -1,8 +1,6 @@
 import Text.Parsec 
 import Text.ParserCombinators.Parsec.Number
 
-type Disk = (Int -> Bool)
-
 main :: IO ()
 main = do 
     text <- readFile "advent15.txt" 
@@ -10,16 +8,15 @@ main = do
     part1 disks
     part2 disks
 
-part1 :: [Disk] -> IO ()
+part1 :: [[Int]] -> IO ()
 part1 disks = print $ head $ filter (canFall disks) [0..]
 
-part2 :: [Disk] -> IO ()
-part2 disks = print $ head $ filter (canFall disks2) [0..]
-    -- where disks2 = disks ++ [(\i -> (11 + 7 + 0 + i) `mod` 11 == 0)]
-    where disks2 = disks ++ [diskify 7 11 0]
+part2 :: [[Int]] -> IO ()
+part2 disks = print $ head $ filter (canFall disks2) [0..5000000]
+    where disks2 = id $! map (take 5000000) $ disks ++ [drop 7 $ drop 0 $ cycle [0..(11-1)]]
 
-canFall :: [Disk] -> Int -> Bool
-canFall ds i = all (\d -> (d i)) ds
+canFall :: [[Int]] -> Int -> Bool
+canFall ds i = all (\d -> (d!!i) == 0) ds
 
 
 instructionFile = instructionLine `endBy` newline 
@@ -27,14 +24,12 @@ instructionLine = diskify <$> (string "Disc #" *> int)
                           <*> (string " has " *> int)
                           <*> (string " positions; at time=0, it is at position " *> int)
                           <*  (string ".")
+                    where diskify n size pos0 = drop n $ drop pos0 $ cycle [0..(size-1)]
 
-diskify :: Int -> Int -> Int -> (Int -> Bool)
-diskify n size pos0 = (\i -> (size + n + pos0 + i) `mod` size == 0)
-
-parseIfile :: String -> Either ParseError [Disk]
+parseIfile :: String -> Either ParseError [[Int]]
 parseIfile input = parse instructionFile "(unknown)" input
 
-parseIline :: String -> Either ParseError Disk
+parseIline :: String -> Either ParseError [Int]
 parseIline input = parse instructionLine "(unknown)" input
 
 successfulParse :: Either ParseError [a] -> [a]
-- 
2.43.0