Skip to content

Instantly share code, notes, and snippets.

@germanescobar
Created June 25, 2022 00:16
Show Gist options
  • Save germanescobar/32bf01a5074b72ef45fc0c88eeac13c3 to your computer and use it in GitHub Desktop.
Save germanescobar/32bf01a5074b72ef45fc0c88eeac13c3 to your computer and use it in GitHub Desktop.
var earliestFullBloom = function(plantTime, growTime) {
console.log(plantTime, growTime)
if (plantTime.every(e => e === 0) && growTime.every(e => e === 0)) {
return 1
}
if (plantTime.every(e => e === 0)) {
const max = Math.max(...growTime)
console.log("max: " + max)
return max
}
let minDays = Infinity
for (let i=0; i < plantTime.length; i++) {
let days = Infinity;
if (plantTime[i] !== 0) {
plantTime[i]--
days = earliestFullBloom(plantTime, growTime) + 1
console.log(`Days for seed ${i}: ${days}`)
plantTime[i]++
} else {
if (growTime[i] > 0) {
days = growTime[i]
growTime[i] = 0
}
}
if (days < minDays) {
minDays = days
}
}
return minDays
};
@germanescobar
Copy link
Author

No funciona :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment