The code will probably crash if there is no loop. However, the kata guarantees that there will be a loop.
An interesting thought. Python has some not-insignificant overhead for calling a function or method though, so I would think it would be slower to call lower() once per iteration instead of once per loop. Besides that, the loop inside lower() is probably implemented in C, which ought to be pretty fast.
Thanks, I think I've eliminated the test cases where empty strings could be passed in.
I deleted those from the global scope. Is that sufficient? I'm not too familiar with the Node environment.
Maybe try using getDay() instead of getUTCDay(). I think creating a new Date object is based in your current timezone, so depending on your timezone, checking UTC might throw off your result.
The original kata required you to directly access the Scales object's attributes. tiriana updated the kata 2 years ago with the better API, but left the old attributes accessible for backwards compatibility. See the kata disccusion for details.
Technically, the kata doesn't define what the result should be for a single-digit ticket number.
However, I would posit that the result of luck_check('1') should be true because 1) it is a valid string representation of a decimal number and 2) the number of digits on either side of the 1 is zero, and the sum of zero digits is defined by convention to be 0; therefore the sum of the digits on both sides is equivalent.
That said, it really only matters what the kata sensei thinks; but we don't know this, since the situation is not in the tests.
This comment is hidden because it contains spoiler information about the solution
Whoops, I missed that when I was reading it. Thanks.
What about duplicates that aren't sequential? Like [1, 2, 1]? Should the second 1 be removed?
[1, 2, 1]
Nice kata, raulbc. There's a minor typo in the kata description under list item (2)—the first example given for the increasing digit order constraint is 769. Maybe that 7 should be a different digit?
What's the grasshopper in the kata title mean?
I just tried the kata, and the method still wasn't static in the initial code. Did you make that change too, Parra?
Ah, I just fooled around on paper until the test cases came out right. I forgot to actually go read the Wikipedia link you posted.