You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1015 B

5 years ago
module Main where
import Day1
5 years ago
import Day2
5 years ago
import System.IO
5 years ago
import Data.List.Split
5 years ago
day1_fuel :: String -> [Fuel]
day1_fuel = fmap (calculateFuel . read) . lines
5 years ago
day2_instructions :: String -> [Integer]
day2_instructions = fmap read . splitOn ","
day2 :: (Integer, Integer) -> [Integer] -> Integer
day2 t = head . execute t
day2_look :: [Integer] -> Integer
day2_look xs = head $ [ 100*noun + verb |
noun <- [0..99],
verb <- [0..99],
day2 (noun, verb) xs == 19690720 ]
5 years ago
main :: IO ()
main = do
5 years ago
r_day1 <- readFile "./app/input_day1"
5 years ago
putStr "[Day 1-1] Fuel needed: "
5 years ago
let fs = day1_fuel r_day1
5 years ago
print $ sum fs
putStr "[Day 1-2] Fuel needed: "
print (sum fs + (sum . fmap calculateFuelOfFuel) fs)
5 years ago
r_day2 <- readFile "./app/input_day2"
let instructions = day2_instructions r_day2
putStr "[Day 2-1] Result:"
print $ day2 (12,2) instructions
putStr "[Day 2-2] Result:"
print $ day2_look instructions