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 think for time complexity you always have to consider worst case scenario, so in this case short circuiting would help practically, but for calculating time complexity I don't think it does.
I should have used recursion :(
Recursively calling itself....duh!
You're iterating many times over the same data. I assume this is because you're trying not to make any assumptions about the shape of the data, but the spec did say the numbers would always be in order.
I could break your code r = "123 S OH 43235 Street Columbus OH 43221", zipcode = "OH 43235"
you could clean up your code (and avoid regex, if you so choose) by using
String#partition
, which is essentially like a split that only splits on the first instance of the separator. This would give you the numbers and the rest in one method call.This comment is hidden because it contains spoiler information about the solution
nice and direct
What's with extra % 2? Was there a reason behind it?