Temperature Code Golf puzzle discussion

Thanks for responding so quickly. Fortunately, I’m working on the puzzles golf code: temperature and Chuck Norris!
However, I really wonder how it is possible to achieve such a small number of bytes.
If you allow me another suggestion, I would be very, very interested if you could show, if they exist, the solutions for old CodeGolf puzzles that are no longer in use. It would make me really believe that such scores are possible. And by the way, it would have a great pedagogical value: discover then reproduce then improve (=pass the master!!) if possible …

Translated with www.DeepL.com/Translator (free version)

There are no “old CodeGolf puzzles” on CG but you can find many example with public solutions here for example:

Also, notice that only the char count matters on CG, not the byte count. It leaves room for additionnal tricks based on compression (basically you can halve your number of chars for a tradeoff of ~25 chars in several interpreted languages).

1 Like

“It leaves room for additional tricks based on compression”: what do you mean by “compression”? Can you explain it to me?
merci.

Intepreted languages can evaluate a string and execute it as code with eval/exec.

Most code is ascii only so every char of the script requires only 1 byte for storing, but if you use chars from a standard like utf-16, every char can store 2 bytes so for example you can store a 200 chars script in only 100 utf-16 chars.

Then you have to play with encoding/decoding and execute the script so the whole process has a constant cost which is usually around 25 chars.

So for example your 200 chars script would become a 125 script.
The longer the script is, the more it pays off.
A script around 50 chars or less wouldn’t benefit from it.

1 Like

merci, j’ai essayé sans succès mais ce n’est pas grave. Cette technique n’a pas grand intérêt. Je peux faire un parallèle avec une photo normale ou compressée: ce qui compte le plus pour le photographe c’est l’image alors que la compression intéresse le technicien qui doit transférer la photo. Les objectifs sont totalement différents même si chacun a son intérêt.
Merci d’avoir pris le temps de vouloir m’expliquer cet aspect de la programmation.

thank you, I tried without success but it doesn’t matter. This technique is not very interesting. I can make a parallel with a normal or compressed photo: what matters most to the photographer is the image, while the compression interests the technician who has to transfer the photo. The objectives are totally different even if each has its interest.
Thank you for taking the time to explain this aspect of programming to me.

Hello,

Can’t understand what’s going on with my code.

Validator 7 fails. Would be great to get the reasons of failures. I didn’t hardcode nothing !

Please read the names of the validators of the non code-golf version of the puzzle - those may provide some hints.

1 Like

Hi to all ! @joguy56, the “Temperature classic” puzzle URL to begin, if necessary :

May this help you ?

For me, only validator 12 fails, this is not even present in the non golfed version :frowning:
My non golfed version submits fine with my code… Any hints on what validator 12 does?

Ah, aperantly some sequence in there which did not yield the right result, no problem… hard to find the problem if you dont know whats wrong :stuck_out_tongue:

Reading this forum - a lot of solutions seems to be hardcoded.
What is the smallest non-hardcoded F# solution? And is there a way for me to see other people’s solutions?

I don’t know what is the length of the shortest non-hardcoded F# solution. However, you can filter the leaderboard to see the lengths of the shortest solutions of a selected programming language. For your reference, mine is currently at 100 characters, it is now the 10th shortest, and it is not hardcoded.

And no, there is no way for you to see other people’s solutions, unless they have published it in the non-golf version of the puzzle or published it outside the CodinGame platform.

I have no knowledge of hardcoded solutions in the top for any language. The validators are known but there’s too many of them to make hardcode relevant.

So you can assume 73 is the shortest non hardcoded F#.

Now, that doesn’t mean it’s pure F#, it might be a system call for another language.

Well, I think some of them are or could be.
There is no test case where 0 is in the list of temperatures so depending on the language you can use it to your advantage.
Also, again depending on the language, you can abuse the way you use sort method and avoid handling the case where absolute value are equal.
And we can certainly find more stuff like that.
To finish, I am pretty sure that your score was 52 in python before replay of solutions… which makes the hardcode definitely possible :stuck_out_tongue:

Can you save my brain and tell me that your 53 is a bit hardcoded :sweat_smile: !

I̶t̶ ̶h̶a̶s̶ ̶a̶l̶w̶a̶y̶s̶ ̶b̶e̶e̶n̶ ̶5̶3̶.̶
You’re right, it was 52, I forgot that.
There is no hardcode but there’s something special, python-related that has no equivalent in my other languages solutions.

you’re welcome and thanks for your answer, I’ll try to find that thing !
I really thought I found it during 5mins, but it fails one validator… But I could turn it in a 56 hardcode with a new stuff to bypass validator :sweat_smile:

Hello, is it ok to verify the second validator or at least give me the test case. my code works everytime except there. plus, the example’s test case works fine with me so i can’t see the error.
I beleive it is broken .

The puzzle works for thousands of players. I suggest you check and test your code further.

If you are talking about my solution then you are completely wrong. It is hardcoded and it is pure f# :slight_smile:

Hey ! Hi
In Temperature Code Golf (Easy)

I’m able to clear all 2-11 validators, Only validators left are 1st and 12th.
Also ALL my test cases are cleared and correctly executed.

** Please Help out me in the Validator 1st and 12th. So that I can successfully clear this challenge.

Regards