The challenge was a little bit ambiguous about the requirement. If I understand correctly, is asking about at least how many resources of each fuel you require to try to smelt iron ingots. With this, I wrote the following solution in JavaScript
const calculateFuelForIrons = ironCubesQty => { const FUEL_DURATION = { lava: 800, blazeRod: 120, coal: 80, wood: 15, stick: 1 }; const smeltingTime = ironCubesQty * 11; return Object.keys(FUEL_DURATION).reduce((result, key) => { const newResult = { ...result, [key]: Math.floor(smeltingTime / FUEL_DURATION[key]) }; return { ...newResult }; }, {}); }; console.log(calculateFuelForIrons(10)); console.log(calculateFuelForIrons(110)); console.log(calculateFuelForIrons(11000)); console.log(calculateFuelForIrons(0));
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The challenge was a little bit ambiguous about the requirement. If I understand correctly, is asking about at least how many resources of each fuel you require to try to smelt iron ingots.
With this, I wrote the following solution in JavaScript