Sorry for the inconveniences I've changed method name to extract_file_name your solution will not pass from now. Please let me know if you want some other convention to be applied.
As a rule of thumb, never modify your inputs. Most langs have primitives that automatically "clone" but arrays are pretty much always mutable, so you should clone them before doing anything.
I might be wrong, but it seems like the random tests (for Ruby) always expect the value of x as the return value.
Random tests
Testing for 12 and [712, 6636, 959, 81, 3734, 70, 1172, 33, 6, 561, 237, 749, 27, 74, 1, 7370, 8, 7335, 53, 5323]
It should work for random inputs too - Expected: 12, instead got: 143
This comment is hidden because it contains spoiler information about the solution
This is concise and nice to read, but becomes very slow for large arrays. Taking (1..1000000).to_a as an input, took nearly 5 min on my (old) machine.
No problem at all! But thanks for the note (and for the kata :-). I've submitted a modified solution, using the new method name.
Sorry for the inconveniences I've changed method name to
extract_file_name
your solution will not pass from now. Please let me know if you want some other convention to be applied.I'll keep that in mind, thanks a lot!
As a rule of thumb, never modify your inputs. Most langs have primitives that automatically "clone" but arrays are pretty much always mutable, so you should
clone
them before doing anything.Oh, I see. I tried a recursive solution and didn't think about keeping the input array intact. Thanks for the pointer :-)
Don't modify the input array ;-)
I might be wrong, but it seems like the random tests (for Ruby) always expect the value of x as the return value.
This comment is hidden because it contains spoiler information about the solution
No worries, thank you for your feed (I didn't think people could name a support function like me, but it was indeed pretty likely).
@myjinxin2015, we were editing the file in the same instant, I changed different things, apparentely; sorry for the inconvenience^^'
Yes, was talking about Ruby. Sorry for not mentioning the language.
Works like a charm now. Thanks for the quick fix!
It should be fixed.
Please re-test.
Thans for you feedback ;-)
I would assume it was for a naming collision: try now that I refactored, cheers :)
In Ruby?
Loading more items...