DEV Community

Discussion on: ReasonML - Advent of Code - Day 1

Collapse
 
dangdennis profile image
Dennis Dang • Edited

I believe there's a possible correction here.

let rec get_total_fuel = mass => {
  if (mass < 9) {
    mass;
  } else {
    let fuelReq = getFuel(mass);
    get_total_fuel(fuelReq) + mass;  <<<< mass should be fuelReq
  };
};
Collapse
 
iamsolankiamit profile image
Amit Solanki

It is, since this is a recursive function, the previous fuelReq is the current mass.