24

My sleeping algorithm 😴😴😴

Comments
  • 4
    Bug: if sheep.length() runs out before you fall asleep then loop will end.
  • 0
    @hube
    Usually it's less than 10
    @KalmyK
    If sheeps run out i'll stay awake and start coding.😍😍
  • 2
    // Much more compact, efficient code
    for(int n=0;me.isAsleep()||n>=o;n++){}
    // Where o is the max number of sheep
  • 0
    this is better as a while loop... just saying
  • 3
    int numberOfSheeps = 0;
    while (me.asleep){
    numberOfSheeps++
    }
  • 4
    Also using plural for lists/arrays are nice, but when the plural of sheep is sheep you need to tread carefully...
Add Comment