--- /dev/null
+
+--import qualified Day1 as Day1
+import qualified Day6 as Day6
+
+main :: IO ()
+main = do
+ --runF1 "day1/input.txt"
+ --runF2 "day1/input.txt"
+
+ Day6.runF1 "day6/input.txt"
type: git
location: https://github.com/githubuser/aoc2021
-executable day1
- main-is: Main.hs
- other-modules:
- Paths_aoc2021
+library
hs-source-dirs:
- day1
- ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
+ day1
+ day6
+ ghc-options: -Wall
build-depends:
- base >=4.7 && <5
- default-language: Haskell2010
+ base >=4.7 && <5,
+ comonad,
+ split
+ exposed-modules:
+ Day1
+ Day6
-executable day6
+executable aoc2021
main-is: Main.hs
other-modules:
Paths_aoc2021
- hs-source-dirs:
- day6
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
build-depends:
base >=4.7 && <5,
- comonad,
- split
+ aoc2021
default-language: Haskell2010
+
+
+module Day1
+ ( runF1
+ , runF2
+ )
+ where
+
f1 :: [Int] -> Int
f1 [] = 0
-- y x(cur)
cur = w + y + x
in if next > cur then (n + 1, cur) else (n, cur)
-main :: IO ()
-main = do
- c <- readFile "day1/input.txt"
- let xs = map read (lines c)
- print $ "Answer1: " ++ show (f1 xs)
- print $ "Answer2: " ++ show (f2 xs)
+readInput :: FilePath -> IO [Int]
+readInput = fmap (map read . lines) . readFile
+
+runF1 :: FilePath -> IO ()
+runF1 fp = do
+ xs <- readInput fp
+ print $ "Answer1: " ++ show (f1 xs)
+
+runF2 :: FilePath -> IO ()
+runF2 fp = do
+ xs <- readInput fp
+ print $ "Answer2: " ++ show (f2 xs)
+
+module Day6
+ ( runF1
+ )
+ where
+
import Control.Comonad
import Control.Comonad.Traced
import Data.Function
let ys = fishesF ages 80
print $ "Answer1: " ++ show (length ys)
-main :: IO ()
-main = runF1 "day6/input.txt"
-