Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Wow, I can't believe I didn't think about doing a mutually recursive method for the even/odd list portion. Constraining the doubling to do the "add the digits" bit is pretty smart too. I just mapped over the digits by length of string representation instead.
Yeah, that’s why I said :)
You can also just subtract 9. I think I will edit the description. I had a hard time writing this step ha ha.
I'm trying it in Ruby.
EDIT
Nevermind, that third test case you posted actually helped me find the final bug in mine. Thanks!
Well, that’s quite simple. You transform your integer into a list of integers. Then, each digit
d
satisfies 0 ≤ d ≤ 9. If you double it, you get 0 ≤ 2d ≤ 18. So if d > 4 or 2d > 9, you just have to sub 10 to get the right digit, and add 1. Which is -9. 16 - 9 == 1+6 == 7, for instance.Didn't got it
This comment is hidden because it contains spoiler information about the solution
Which language? I added the 500 to Haskell, so I can't say anything about the other languages.
Are you sure there isn't a typo in one of the credit card numbers (the 3rd test when you submit)?
I grabbed 500 card numbers from that website and tested locally against my implementation and it works fine.
I’m surprised how people understand the sentence “add the digits of the doubled”. The solution only requires a sub, come on guys, no need for digits! :D
Yeah, I forgot what -10 + 1 is. :D