[Community Puzzle] Snail Run

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @Eurostar02,validated by @ThomPuce,@Murat_Eroglu and @FredericLocquet.
If you have any issues, feel free to ping them.

What happens if two snails want to occupy the same cell at the same moment because that is the shortest path to their dest?


it’s the shorter path that counts here there are no collisions between snails, snails teleport

i am trying to create episode 2 with collision


You should specify it in the description :

  • Two snails or more can be at the same place at the same time (no collisions)

There is no collision nor change in speed nor effect on each other’s path. The snails do not effect each other.

Though there is a solution that does not rely on mapping the snail paths so exactly.


Because of CG Web Dev made the topic creation too hard and glitchy i’m actually reply directly here because it rely on the subject so actually I’ve done this puzzle but i can’t get 100% in submit with validators I’m stuck at 75% because of test 3 & 8 so my question is how can find what’s going on and why it fails, can we have their unit test to check why I’m failing at these steps?

I can share my code for anyone who want help me.

Thanks in advance :slight_smile:

1 Like

I think you mean Validators 3 and 8 instead of Tests 3 and 8 (tests are the ones you can see, validators you cannot).

Validator 3 is the same as Test 3 except for the speeds of the snails. Try generating some random numbers within the constraints to test out your code.

Validator 8 is the same as Test 8 except for the map. The lanes are horizontally mirrored and then ordered and numbered differently.

Hope this helps.

Hey ty for ur answer i tried random numbers or speed for V3 it works and get the best snails to win and for V8 tried also to horizontally mirrored my lanes and replace numbers in different places and it works too but still doesn’t solve the problem why it doesn’t pass these validators even if my code works i will share u my code if u want : https://codeshare.io/MNENNp

Validator 3: For a start, try speedSnail of 1, 2 and 3 (note: not the input of the validator). Your code gives 2 as the answer, while the correct answer is 3.

Validator 8: I tried your code on the validator, and the following error message appeared:

Unhandled exception. System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter ‘index’)
at System.Collections.Generic.List`1.get_Item
at Race.FillMap on line 413
at Solution.Main on line 532

1 Like

i got the puzzle done… but i wonder if for further puzzles to consider more than one “#” in each row. thank you for the fun!

Hey bro, i would thank you for ur details, now i got 100% and finally done with this puzzle, but i’ve a question for u, actually how do u call the validator for a specific code like u did for trigger the exception?

Glad to know you’ve made it! :tada:

Validators are accessible in the contribution view of a puzzle. Normally you need to be at higher levels to have access to that view.

“Though there is a solution that does not rely on mapping the snail paths so exactly.”

I think that this fact has to be stated in the puzzle description a bit more vivid.
I was confused buy all the tiny details (do snails allow to overlap and what not) thus implemented the boring BFS approach. Only when I was checking other solutions, i’ve figured out that there is significantly less involved solution exists.

Hello! Fun puzzle!
I think there might be some ambiguity about the winner number. Indeed if two or more snails arrive to the finish at the same time, the winner number is not defined by any rule but by the implementation of your solution. In my solution all Tests passed with an “<” update rule then some Validators failed. I replaced by “<=” and it worked. It might worth to check, if it is possible to add some specific rule

The statement mentions:

For each race there is only one winner.

So there shouldn’t be the situation where two or more snails finish the race at the same time.

In some of the test cases, there is more than one winner.

Would you please list which test cases, and demonstrate how there is more than one winner in each of those test cases?

Before posting my solution, I still wondered if validators may have some maps with empty cells where snails couldn’t walk through. It would have been funny ;)… Else it’s good with Manhattan.
Nice puzzle

Thanks for the puzzle, it was a fun one.
For the ones having issues maybe this could help.


To know what I was really facing I created a function that just prints the grid/field/board.
This will help you to know what to expect and what not.
Then we need a list/array of the snails and we need to know their id (number), position and speed.
And on the other hand we need another list for the goals, for this list the positions is enough.
Then, we can use the Manhattan distance to know what goal is closer to each snail and with that distance divided by the speed of the snail we can know wich one will arrive first. You don’t need to “simulate” the race turn by turn as there are no colisions.
The only thing you need to take into account is that if the division is not exact that snail will need one extra turn (distance = 5, speed = 2, division is 2.5 (2 if you use only integers) but as it is not an exact division it will take 3 turns to reach the goal).


I succeed by looking at the forum => the instructions are not clear at all.

The solution is quite easy if you understand that it you have a speed of 3 you can move 2 on the right and one down and the same turn !

Also, the test title does not help at all: Why is the #3 names “only one arrives” since they all arrive!

If you had to move exactly from the number of cells has given by your speed (and perhaps consider that only the last move can be shorter than your speed to understand the example) then only snail 2 arrives in this case.

So the difficulty of this puzzle is that the statement is really badly stated im my opinion!