Skip to content

Commit

Permalink
Day 1b with debug
Browse files Browse the repository at this point in the history
  • Loading branch information
tjpalmer committed Dec 2, 2019
1 parent c02b407 commit 56f76ad
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions 2019/01/sumfueldeep.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Debug.Trace

main = print (findFuelDeep 1969)

mainMore = do
content <- readFile "sumfuel-input.txt"
let contentLines = lines content
let masses = map (read :: String -> Int) contentLines
let fuels = map (findFuelDeep) masses
print (sum fuels)

findFuel mass = (div mass 3) - 2

findFuelDeep mass
| fuelMass <= 0 = trace ("a " ++ show mass ++ ", " ++ show fuelMass) $ 0
| otherwise = trace ("b " ++ show mass ++ ", " ++ show fuelMass) $ fuelMass + findFuelDeep fuelMass
where fuelMass = findFuel mass

0 comments on commit 56f76ad

Please sign in to comment.