Created
July 17, 2017 22:56
-
-
Save aspencer8111/d902d01cbe31408daa61c7816ff05c1a to your computer and use it in GitHub Desktop.
Solution to Plan your day kata
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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