DEV Community

Discussion on: Daily Challenge #140 - I love you, a little, a lot, passionately ... not at all

Collapse
 
wheatup profile image
Hao

Very simple but effective answer!
Just two improvements:

  • (n + 6) % 6 seems a little bit redundant here, n % 6 does the same thing.
  • Flower with only one petal should return not at all, but this returns I love you.
Collapse
 
savagepixie profile image
SavagePixie • Edited

Thanks for your feedback! I wasn't sure how the operator would work when the result of the division is smaller than one and had no time to test it, so I went for an option I was sure would work. I'll change my solution accordingly.

Collapse
 
nickholmesde profile image
Nick Holmes

You're right about the (n+6)%6 (its correct, but the +6 does nothing).

However, SavagePixie cleverly rotated the items in the array down one position, to essentially pre-calculate the -1 offset for the first item - so its working correctly.

Thread Thread
 
wheatup profile image
Hao

Ah, I see. Didn't pay attention there, my bad. Thanks for the explanation. 😀