49
cleyton
7y

Coming out the test today. There is a message from the Professor in the back of the test.

Comments
  • 3
    I'm a simple man, I see Portuguese people, I ++. Also, nice algorithm!
  • 4
    @NyxMC that's even worse :s
  • 1
    @NyxMC
    int nsheep = -1;
    while (++nsheep < sheep.length && !me.asleep);
  • 14
    guys.... why limiting sheeps?

    var nsheep = 0;
    while(!me.sleep()){ nsheep++;}
  • 2
    @shivayl estranhissimo ver gente falando português por essas bandas
  • 4
    @LeoRiether @nyxmc only because you can doesn't mean you should! Your one-liners take double the time to read, are hard to extend and are very error-prone.
  • 1
    Good luck! Boa sorte!

    There are a lot of Portuguese speakers here
  • 1
    Wait what?

    Where is sheep array defined prior to calling length on it? Also like others mentioned why run out of sheep by having a finite number.

    Also why start two counters at 0 just to increment them both at the same rate numberOfSheeps will always be equal to i in which case using i in the loop is pointless.
  • 0
  • 0
    That loop is not optimized.
    Tell him to use ++i instead of i++ to avoid creating one unnecessary object
Add Comment