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.
pretty cool!! my solution uses the same logic but this code snippet is crisp and clear!
I'd suggest using Array#length or Array#size instead of Array#count here as they don't check whether a block was given.
Awesome solution overall, the array-adding one-liner is pure gold for readability here.
I encountered the same problem (with the very obvious answer in Ruby), and hadn't a clue how to fix (circumvent) the problem in the test cases. While debugging, I put a
p string
as the first line in the method... and got the solution accepted. You might want to try that.I got that also. I don't how I can fix that.
Please fix!
Thanks Matt, that I'll do :)
Yeah good point, this still isn't fixed. Thought it was an issue with my code as I was using the "permutation" method!
This test is super easy in Ruby, nontheless the submit tests do not pass.
It prints
Any clue ?
Has anyone found a non-brute force solution they want to summarize? I know there's a lot of pathfinding theory in games and such. It's also clear you could optimize the common case (always guess "towards the exit" as a first priority), but I couldn't think of a way to optimize in the worst case.
With this data structure you can index into the map as
map[x][y]
, so you get the natural-ness of x,y coordinate addressing. I actually thought it made great sense. Is it more intuitive a different way?For JS: Reusing the same map instance across tests has suprising side effects.
While it's true we should be aware of whether or not we're mutating references, but I'd probably like that explitly allowed or disallowed in the instructions in this case.
Marking
visited
coords in the map reference would be awfully convenient if it were allowed! Of course we could copy but in JS you need a deep copy so it's not a terse solution.depends how the tests are written, sometimes the same object is passed into your solution and a validating solution. So if you modify the array the validting solution will get your modified version and will return a different result than expected.
it's good to stay safe and make a copy of any objects passed in usually :)
Thank you very much ! I tried it before but since I am a noob I was not very confident.
So I tried again with a deeper copy (using mapito = minemap.map { |e| e.dup } in Ruby) and I worked.
Still... it is the first time it happens. I have no idea how I can avoid this in the future.
make sure you're not modifying any parameters, make a copy of the map array and use that.
This comment is hidden because it contains spoiler information about the solution
Loading more items...