[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?

2 Likes

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

2 Likes

You should specify it in the description :

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

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.

Hello,

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?

Hello,
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.

Spoilers

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).

Regards,

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!