[Community Puzzle] Moves in maze

Hello
All the tests pass but when I submit the code I only get 86% because test 3 doesn’t pass.
Any kind soul to take a look and tell me what doesn’t pass?
Thank you

Thank you @Remi, @franca1s I was missing an important check in my algorithm.
@ElDadz the key for #3 is in this statement:

The maze is periodic: if you go left you appear on the right if there is no wall, and vice versa, similarly with up/down.

Yes test 3 is working before i submit
But when i submit it doesn’t work

Ok, I checked, and there is a difference between the test and the validator : in the validator your start on a border. Hope it helps you.

EDIT : you start on a border, but you don’t pass through the border at this point (wall on the opposite of the grid).

Maybe this custom test case can help you to debug :

6 3
...S.#
#####.
####..
32101#
#####4
####23

Hello Remi
Thank you for your answer
I just used your custom test case in vscode and it’s working properly, i get the same result as you

:thinking:
I don’t see any other difference between the test case and the validator.

Spoil : real validator
10 5
#.#####.S#
#.##..####
..##..#...
####..#.##
#....##.##

Hi,

All is good except validator 4. I can’t find why as I don’t know the input for it. Can someone help?

The only real difference I can see between the test and the validator, is that there’s a wall next to the start. Somthing like that :

..........
..S.......
.###......
..........

Thanks. Output is

3212345654
2101234543
3###345654
4323456765

Can’t see what’s wrong.

Validator sent in private message.

I get the right output, but validator is still wrong. Weird.

Solved thanks to @Remi.

There was a segmentation fault because I malloced a char** with sizeof(char) instead of sizeof(char*).

First thing you think is recursivity, function calling itself, that was easy to solve ! But I looked at some others solution and how Queue work to “avoid” the normal recursivity ?

You can code a BFS without recursivity.

Hello,

All tests ok but validator 6 doesn’t. If there is no difference with test 6 as I read in previous posts, I can’t find why. Can someone help, maybe with the input?

Only difference I can see is that validator is the only one to reach the character ‘W’

Test to ensure that your code reaches W:

38 3
######################################
#S...................................#
######################################

Expecting:

######################################
#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ#
######################################

*Edit: Adding dimensions to input

Solved, thanks @Harry.B. I hadn’t thought to check my alphabetical list ^^’

1 Like

Hi!

I’m passing all testcases, but when I submit my answer, I get “Through borders” wrong.

Any ideas about what’s going on?

For info:

  • I’m using a FIFO queue, and I’ve checked that the moves number is never decreasing in the queue
  • Once a cell is filled with something different than “.”, it’s skipped.
  • If I was handling the maze dimensions wrongly, I would have other puzzles wrong too.

This test will check for the only difference I can see between test and validator:

4 4
#.S#
####
#.##
#.##

Expecting:

#10#
####
#3##
#2##

If that provides the expected result, do you want to private message me your code and I could take a look ^^

Hello Harry.B!

Thanks for your reply! I didn’t get a notification, so I didn’t see it until a few minutes ago. The test gives the correct output, so I’m sending my code to you via PM.

Let’s see which is the problem :slight_smile: