# [Community Puzzle] Robot show

https://www.codingame.com/training/easy/robot-show

Created by @java_coffee_cup,validated by @Gorbit99,@Schwase and @JBM.
If you have any issues, feel free to ping them.

@java_coffee_cup yeah this puzzle makes me happy too haha

Hello, I’m having trouble with validator 5, all tests and all other validators are OK, but not the 5th. My strategy is to always have the outer-most robots facing the other side, then next robots are facing the other way…etc ( looks like > < > < > < > < ) and I simulate twice if the number of robots is odd (changing the side of the center robot). Is my strategy correct or am I missing something?

You do not need to simulate all the combinations. Draw on a paper the lines representing the paths of the robots and you will see a nice property when two robots bump into each other.

3 Likes

In example I see an initial distance of 3 (robot in 2 and 6), and so they meet in 4; but for even distances? If robot are in 3 and 6, where do they meet, in 4 or in 5?

In this case
. . . > . . < . . .

where and when they meet?

1 Like

init distance in that case is 4

will be in the middle, 4.5

2 Likes

Just a friendly reminder to anyone who is trying brute force that this puzzle was labelled easy for a reason. Pay closer attention to the tag .

3 Likes

That was exactly my thought: Oh man, why it is ‘easy’, # of possible robot facings grow exponential… I started to use my brain only after reading your post…
Excellent puzzle!

1 Like

Man, this was a physics problem I encountered quite a couple of times, nice!

For all of you trying to figure this out, think of it like this.
Imagine each robot is carrying a small cube on top of it. Every time it hits another robot, they swap cubes.
What is the trajectory of the cubes?

9 Likes

Took me 3 days to reach that “Aha!!” moment.

Ha ha, nice one.

One could argue this is more an experiment in human psychology than a programming puzzle, though.

Creative approach, special insight to a problem, thinking out-of-the-box, seeing things in a different perspective…

People (including programmers) aspire to have these qualities.

Put down logic and algorithms for a while. Time for brain exercise.

1 Like

Well, yes. I didn’t mean to say it doesn’t belong here, otherwise I would have said so.

What I meant by “experiment in human psychology” is that, if you tell people a story involving agents (here: the bots), they naturally assume these agents have some kind of identity that matters and one could say the key to the puzzle is to overcome this instinct.

And I think you – as the creator of the puzzle – would agree the specification and the example time slices were deliberately crafted to hide the underlying simplicity (there is a reason you did not include a snapshot at t = 3 s).

In any case, it made me smile. So thank you very much for your effort providing the content!

1 Like

Awesome puzzle. “They had us in the first half not gonna lie” haha

2 Likes

Wow … This is an incredible comment, i figured out everything !!! I was coding deep into a full simulation step by step for each bots… something crazy … and here you go with a simple view of mind that makes everything so simple ! …
I feel stupid lol
Thx

1 Like

I feel stupid lol

Same… After a “naive” brute force approach I created an optimized one where I collapse bot directions whenever possible (cursing the labeling as easy) - I knew it might be not enough, but had no other idea. And still got two timeouts. Yeah. Well. At least I practiced a little bit of recursion, abstraction and DFS

2 Likes

Oh my… the description is so designed to set you off track.

I didn’t try to brute force my way out of it but needed to visualize a few test patterns to finally get the point.

Here is another hint:

``````.>...<...<<..
..>.<...<<...
.
.
.
``````

Try to write out a few of this and you WILL feel stupid.

1 Like

well i m not far from resolve it but get stuck with a result equivalent or ofter with 1 less
in test 2, i found 19 and the result is 20. here is a trace if someone can help.

``````input
20
7
1 2 20 7 6 10 14

[init state]
=====
time: 0
> <       > <     <       >           >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:
- the bot 2 has exited !

=====
time: 0.5
X         X     <         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:
- impact between 0 and 1
- impact between 3 and 4

=====
time: 1
< >       < >   <           >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:
- impact between 0 and 1
- impact between 3 and 4

=====
time: 1.5
<   >     <   > <             >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 2
<     >   <     X               >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:
- the bot 0 has exited !
- impact between 3 and 5

=====
time: 2.5
> <     < >               >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 3
X     <   >               >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:
- impact between 1 and 4

=====
time: 3.5
< >   <     >               >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 4
<   > <       >               >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 4.5
<     X         >               >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:
- impact between 3 and 4

=====
time: 5
<     < >         >               >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:
- impact between 3 and 4

=====
time: 5.5
<     <   >         >               >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 6
<     <     >         >               >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:
- the bot 6 has exited !

=====
time: 6.5
<     <       >         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 7
<     <         >         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:
- the bot 1 has exited !

=====
time: 7.5
<           >         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 8
<             >         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 8.5
<               >         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 9
<                 >         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 9.5
<                   >         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 10
<                     >         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:
- the bot 4 has exited !

=====
time: 10.5
>         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 11
>         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 11.5
>         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 12
>         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 12.5
>         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 13
>         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 13.5
>         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 14
>         >
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:
- the bot 5 has exited !

=====
time: 14.5
>
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 15
>
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 15.5
>
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 16
>
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 16.5
>
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 17
>
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 17.5
>
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 18
>
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 18.5
>
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:

=====
time: 19
>
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

============
Information:
- the bot 3 has exited !

19``````

No sure but if you change the robot in the far-right to face Left, will it make a difference?

1 Like