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.
I did the same solution. I guess they would rather see some clean code than efficient code.
Can someone explain this in more detail? I tested this solution with greater-than-16-character strings, and it seems to work fine.
EDIT - I think I got it, the sum method represents its return value as a 16-bit integer by default, so if the sum of the ascii values is greater than 65,535, the sum will overflow and start over from 0. You can pass an optional argument to the sum method to increase this though. 'Hello world'.sum(32) will use a 32-bit integer to represent the checksum. Am I understanding that correctly?
I'm gonna give this one a vote for best practice. It's actually really expressive if you're familiar with the methods being used. And even if you're not, it's concise enough that you can look it up pretty quickly.
Thanks :)
It doesn't work for strings with more than 16 characters.
... until you realize that this solution is wrong and it's far from obvious what that method returns. The solution is still clever and shows the lack of tests, though.
Lame joke accepted ;)
Oh, rest assured that in production I will never do that (and actually I am usually the one commenting the most), but here is competitive coding: you are meant to show off a bit, plus I found juggling with more things in one line it is great practice.
Consinder it like training with extra weight ;)
And I just noticed I could simplify things much further, as you don't actually need
||[]
on Ruby, ops!/me goes back training in the hyperbolic time chamber