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.
Added in this fork
Added in this fork
No random tests.
No sample tests.
.
@Wei-LiangChew I'm a little late but then the while loop will iterate over with n - 1 = 8 (and so on)
But what if the largest 5-digit number in
digitsdoesn't start with 9?Hey Ricardo! Yeah I thought it was you. I just started codewars :) Thanks man. Hope you're doing good as well!
Hey Freddy, what's up bro? This is Ricardo, from Ayu!
Hope you're well
I just got it, thanks!
I think it means that if a 'Bag' object does not have any elements in it, then it should not blow up the tests. So your code should still work even for 'Bag' objects that happen to not have anything in it.
I don't know what it means with "Empty bags should pass all tests.", anybody?
I also can't see the output for any kata.
Thanks!
Nice one-liner. The Array allocated by
split('')orcharsgives this algorithmO(n)space complexity, it's possible to solve this withO(1)space complexity. All voted on solutions share this problem.Great Job, I just started to learn regex, and I find it really useful ( rather than iterate over each caracter and check), it could be a little faster if you replace .sort.pop for .max, I'm still not sure how regex does it, because in order to find all chunks starting with 9 and 4 more digits it still needs to iterate over all the array, so Im not sure why my solution is slower, maybe because the regex is executed in a binary library rather than interpreted like ruby ?
I really appreciated the sense of humor in this kata! It made it a lot of fun. But it would probably be a good idea to rename the #each test, because
#each:
should execute the block for each item in the bag. why are you messing with this method? work on #every? instead.
is very confusing, and seems to imply that we cannot use the #each method in the kata. So this kata could use some revision for clarity. Other than that I liked it though.
Given that each and count have already been implemented, you shouldn't need to fully define the Bag class or its initialize method. These should already exist. Your implementation should focus strictly on every? and any further helper methods you need to create for that to work.
Loading more items...