[Community Puzzle] Detective Pikaptcha EP2

He should visit every cell. The “follow a wall” means the order of the next cell when he reaches a junction. For example on the cell (1,0) he can step on the (2,0) or (1, 1). If he follow the left wall then the next cell is (2, 0), otherwise it is the (1, 1).

1 Like

I’ve been scratching my head a bit over this one. I’ve written a general solution to the problem which produces ‘correct’ results for 1-6, but, while I would expect it works for 7 & 8, the game times out. I know that walking the maze is going to take a long time, but that is the problem, right?..

I’ve noticed there is a possible trick to this, which involves counting adjacencies. It would seem to break down in test case 2, at least.

So, is this supposed to be a simulated walk? And, if so, why do 7 and 8 time out? I don’t think my code is as unoptimised as all that :-p

The last 2 tests are fairly big, but another possibility is an infinite loop somewhere in your code.
You should check how many steps you compute, for test 8 I get 3996.

1 Like

Thank you for your reply.

I’ve figured out what the problem was. I had debug output to show me what was going on at each step, and apparently that was getting read by the game system as my actual solution output. The smaller problems had less steps, so less debug output, so there was sufficient space in the feed for both. I don’t know if this is an issue with the system as a whole or just this problem. I was confused because my debug was going to std.err, not std.out, so I didn’t think there’d be that kind of overlap.

Anyway, solved now, and thank you again for your help. :slight_smile:

1 Like

No matter it is output to err or to out, both are part of the processing requested by your program. All output time is counted into the processing time.

This is a “feature” common to all online coding and judging systems.

You can comment out the std.err output to save plenty of unnecessary process time. Sometimes I keep the err statements for my debugging but have a boolean switch to turn them off easily in the final Submitted version.

1 Like

Hello.

In this start context :

#0^0#

With Pikaptcha follows the right wall (R).
Good result is

#011#

or

#110#

Thanks

input

5 1
#0^0#
R

output
#110#

1 Like

Hi @java_coffee_cup,

Are you sure that that is the right output? I was looking at the demo that it’s in the game’s homepage and there is a situation identical to what @BRemy asked you when Pikaptcha is inside the T shaped enclosing. Assuming that the direction to follow in that case was R (which it seems so if you look at what path Pikaptcha is following), Pikaptcha goes first right and then left and not the other way around.

Now, I might be making a mistake in my assumptions so please let me know where I went wrong with my reasoning.

Thanks

In all cases, if it is give that R is the side to follow, Pikaptcha will always start in a location where his immediate R has a wall.
Which test case confuses you?

That makes sense. I don’t have a problem with any of the test cases really… it’s just that I read @BRemy 's post and your reply and I was confused by it. @BRemy was asking if your input is of this type:

5 1
#0^0#
R

would you expect your output to be either

#110#

or

#011#

You replied that the first is the right case but Pikaptcha is exactly in the middle and doesn’t have any wall directly next to him. In this case, I thought that the “wall” to be considered when making a turn would be the bottom of the array rather than the top, i.e. it’s as if Pikaptcha is facing a wall in a narrow corridor and he decides to turn right. In the game, as you said, Pikaptcha is always placed in a way that a wall is on either side of him depending on which “side” has to be followed, i.e. R or L, so there is no problem there. However, I was genuinly interested in knowing what would happen if we encountered a case like the one @BRemy showed and why would you have Pikaptcha turn left rather than right in that case.

Hope this makes sense to you :slight_smile:

That situation is not happening in all test cases becasuse we don’t want to confuse anyone.

Suppose for some reason it is made to happen, a reasonable understanding is to allow Pikaptcha to run forward in his given direction until he crashes at a wall, then he will either turn L to allow his R hand to touch the wall, or turn R to allow his L hand to touch the wall.
If that kind of assumption is actually made to happen in a game, the statement should have explained it.

2 Likes

Well explained. Tks.

1 Like

That checks out! Thanks… I came to see it that way on my own after reconsidering what it means to look at either L or R for Pikaptcha. Especially because, if he crashes into a wall, effectively the conditioning should reflect the swapping of R and L, very much like your R becomes your L in a mirrored image.

Yeah, that got me too. It took waaay too long for me to realize the extra debug prints were the issue.

Hello,
got a problem with python3 :
just to have the dimension of the structure , it takes already 2s… impossible to do anything else:

just the basics :
import sys
import time
debut=time.time()
L, H = [int(i) for i in input().split()]
p1=time.time()
print(p1-debut,file=sys.stderr, flush=True)
exit(0)

answer : 2.3567681312561035

What can I do here ?

Hey.
You have to start your time measurement after the first input and to stop it before your output. Otherwise you measure the referee time.

10 Likes

well , thanks for your answer,
got my probelm solved, i Forget the R case … stupid me

Is it always guranteed that Pikaptcha has a wall on the side he’s supposed to follow?
I don’t understand what to do in the case he’s in an open area and doesn’t have walls to hug.

1 Like

In the game all starting points have a wall for touching and following.

To make an out of scope assumption, in case there is a new map without a starting touching wall, just go forward until you find a wall.

1 Like

I think there could be a couple more test cases in this one, specifically for the following edge cases:

  1. A 2x2 blank square similar to the sparse validator
  2. A test that uses L in such a way that it would fail if they followed R
  3. Each of the starting directions that fail if the correct starting direction is not used

Also I think the constraint that detective pikaptcha will be touching a wall in the starting position on the side that they should follow, should be in the description so that I don’t have to find it here.