From f50552707fb22f14b459006c3904c5bee63418c8 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Sun, 1 Dec 2019 14:52:25 -0600 Subject: [PATCH] Cleanup --- 2019/1.moon | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/2019/1.moon b/2019/1.moon index 3813185..62309dd 100644 --- a/2019/1.moon +++ b/2019/1.moon @@ -1,21 +1,12 @@ -- https://adventofcode.com/2019/day/1 require "common" +input = -> input_for_day(1)\gmatch "%d+" -input = input_for_day 1 - --- part 1 - -nums = -> input\gmatch "%d+" mass_to_fuel = => -2 + math.floor @ / 3 - -print "Part 1:", reduce nums!, 0, (n) => @ + mass_to_fuel n - --- part 2 +print "Part 1:", reduce input!, 0, (n) => @ + mass_to_fuel n fuel_for_fuel = => f = mass_to_fuel @ - print "fff:", f if f < 1 then return 0 else return f + fuel_for_fuel f - -print "Part 2:", reduce nums!, 0, (n) => @ + fuel_for_fuel(n) +print "Part 2:", reduce input!, 0, (n) => @ + fuel_for_fuel n