Don't Panic - Episode 1 - Codesize - Puzzle discussion

if i am unable to solve a puzzle from where can i get the solution?

donā€™t you have fun from finding solution yourself?

3 Likes

Sometime for some problem our mind doesnā€™t work.
Right now this problem is giving me a lot of headache.

1 Like

Iā€™m also very surprise by the score of the top player.
I must miss something, because, for me, 50-100 characters looks impossible to achieve.

My algorithm is as follow :

  1. I save first variables in an array
  • I then save elevators in a dictionary
  • In the main loop I then get the position, floor and direction
  • with which I compare to the position of the elevator on the current floor
  • if the positions and direction match, I Wait, else I Block

This looks to me like the simpliest way to solve this problem.
The first 3 steps of this get my code above 100 chars, so there must be something I miss

Any hint in python would be appreciated, Iā€™m currently around 240 char.

@JuanCortes: Does it exist any way in Javascrit to avoid the three readline().split(ā€™ ') ? Your 106 chars are awesome to me! :slight_smile:

@fiero At the very least declare a function that wraps it, with a shorter name. Mind you, you can use arrow function expression and anything ECMASCRIPT 6 standard. In my particular code (by no means the shortest in javascript) I only have one readline(), in the second portion of a for loop.

2 Likes

@JuanCortes Thank you very much for your tips. I will try to do it better. Thanks!

no youā€™re not.

Is it just me, or does the initial list of elevator positions not match the actual location of elevators (test case 06)?

The upper-left screen shows elevators evenly staggered, but the initial list is not equally staggered:

Standard Error Stream:
Debug (initial): i=0 elevatorPos=12
Debug (initial): i=1 elevatorPos=14
Debug (initial): i=2 elevatorPos=14
Debug (initial): i=3 elevatorPos=12
Debug (initial): i=4 elevatorPos=12
Debug (initial): i=5 elevatorPos=14
Debug (initial): i=6 elevatorPos=12
Debug (initial): i=7 elevatorPos=14

What I see on the screen:
i=0 elevatorPos=14
i=1 elevatorPos=12
i=2 elevatorPos=14
i=3 elevatorPos=12
i=4 elevatorPos=14
i=5 elevatorPos=12
i=6 elevatorPos=14
i=7 elevatorPos=12

Doh, never mind, I see that the elevatorFloor is not the same as i.

3 Likes

Iā€™ve been having issues where the cloneFloor input isnt updating until 1 or 2 turns after the leading bot moves to the next floor. Iā€™m not sure if its something that I should be coding around and its ā€œintendedā€ or if its some sort of glitch with the game loop and inputs.

Hmmā€¦I came back this morning and refreshed the IDE. Using the same code it now works correctly. must have been a hiccup.

Hi, I am having the same exact problem!

I am using C++, How do I solve it?

Hi NikBomb,

If you mean you are having the issue I had with the lag with the inputs then all I can tell you is try to refresh and/or close and reopen the page. I remember it driving me nuts and then the next day it was back to normal and my tests were passing with the same code. It must have been a browser issue or somethingā€¦

1 Like

Thanks mralston. I found that the lag in the input in my case was introduced by a wrong structure of nested ifsā€¦ Go figure :smile:

IMHO Donā€™t Panic Chapter 2 makes a better code golf, since simplifying your algorithm makes more significant difference there. For chapter 1, quite some portion of the code is about parsing inputs.

Interesting puzzle! I learnt how little I knew about the ā€œscanfā€ formatting string and variable declarations in C. Worth noting is that C and Python are comparable, regarding the code length minimization goal. I am not proud of my C code quality, because I know that it will segfault for sure when the problem has more than 10 levels. It might also segfault with ten or less levels when running on some other platform, because I let scanf to write a zero byte to god knows which memory location. The validator may say that it is OK, but I wold not run it on my own systems :slight_smile:

is there a bug or the code at 27 char is really possible (excluding randomly working solution)?

Use other languages.

wow that really messed me up