package main import ( "fmt" "math" helpers "git.bullercodeworks.com/brian/adventofcode/helpers" ) func main() { inp := helpers.StdinToStringSlice() fmt.Println("Fuel Required:", part1(inp)) } func part1(inp []string) int { var total int for _, v := range inp { total = total + part2(fuelRequired(float64(helpers.Atoi(v)))) } return total } func part2(fuel int) int { ret := fuel for fuel > 0 { fuel = fuelRequired(float64(fuel)) fmt.Println(fuel) ret = ret + fuel } return ret } func fuelRequired(mass float64) int { res, _ := math.Modf(mass / 3) if int(res)-2 < 0 { return 0 } return int(res) - 2 }