Skip to content

Instantly share code, notes, and snippets.

@aspencer8111
Created July 17, 2017 22:56
Show Gist options
  • Save aspencer8111/d902d01cbe31408daa61c7816ff05c1a to your computer and use it in GitHub Desktop.
Save aspencer8111/d902d01cbe31408daa61c7816ff05c1a to your computer and use it in GitHub Desktop.
Solution to Plan your day kata
function dayPlan (hours, tasks, duration){
var minutesAvail = hours * 60
var totalWorkMin = tasks * duration
if(totalWorkMin > minutesAvail){
return "You're not sleeping tonight!"
} else {
var answer = []
var timeRemaining = minutesAvail - totalWorkMin
var chopped = timeRemaining / (tasks - 1)
for(var i=0; i<tasks; i++){
answer.push(duration);
answer.push(Math.round(chopped));
}
}
answer.pop();
return answer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment