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.
The test cases need to be expanded -- multi-character markers, things that need to be Regexp escaped, etc.
Ah, but I'm using triple dot instead of double dot. The triple dot range operator does not include the end value.
http://stackoverflow.com/questions/9690801/difference-between-double-dot-and-triple-dot-in-range-generation
BTW, using ints.size like that is maybe not a very good idea.. ints.size > maximum index of the array. Use ints[i..-1] works great.
Note: this is a really lazy way to do it. It's effectively O(N^2), where an optimal solution is O(N).
FYI, you could shorten your first 6 lines in a variety of ways:
bits = bits[bits.index('1')..bits.rindex('1')] #take the range of characters from first 1 to last 1
or
bits = bits[/1.+1/] #the same, but a simple regex
You could also do what I did, which was to convert zeros to spaces and then just do a String#strip
Hi, while I was writing the solution I took it for granted but when you asked the question it made me search for why it works, here is a link expalinaing why it works for ruby 1.9+.
https://stackoverflow.com/questions/17355316/hash-ordering-preserved-between-iterations-if-not-modified
May be worth reading the discussion on use of "and" in number representation here: http://www.codewars.com/kata/525c7c5ab6aecef16e0001a5/discuss#5276d6654c2333791a00027c
Genius! :D
I just wanted some test data -- see my comments on the kata. My solution worked fine, but some unexpected data caused an issue, and the error messages/data weren't very specific.
That's Brutal
Thanks!
Great challenge! It shows you how hard option parsing really is -- something I didn't even think about =)
"Five hundred and twenty-one"
"Five hundred twenty one"
"Five hundred twenty-one"
"Five hundred and twenty one"
Why should it be the last one and not any of the first three? The tests expect rigid conformity to a standard you don't lay out explicitly. That is to say, the first three are "not allowed" but the final one is "allowed" -- and it requires an AND to be placed just so. It gets even more hairy when you realize that one could have, for example, beliefs like this: "one hundred and five" is correct, but "one hundred five thousand one hundred and five" is also correct -- you could be placing "and" ONLY in the final hundreds group. In fact, that's how most people speak: "the house costs two hundred thirty thousand, four hundred and ninety-nine dollars."
The problem is fine, it just has three main issues: unspecific rules, ambiguous test cases with unhelpful error messages, and a lot of grunt work to tackle the meat of the problem. Those, to my view, are all solvable, but they require some work.
Fun kata, not quite sure why 0 wouldn't evaluate to 0th... that seems counter-intuitive to me, and isn't listed as a requirement either in the directions or in Wikipedia.
First, I am surprised that you want the way to write a number to be defined, if it's not obvious then to explain it would take, IMO, far too long to do unambiguously. Further, I'm not sure what you mean by allowed/not allowed. I've said the range of possible numbers; what might not be allowed, as an example for me?
Second, yes the choice of how to represent 'point zero' is quite arbitrary, it's just (slightly) more difficult that way.
Clearly you don't like this problem. Fair enough; and if the community doesn't like it, I can delete it.
Loading more items...