Temperature Code Golf puzzle discussion


Thank you !!
In the 4 tricks you told me I just know one ( global variables ), the 3 other are very helpful :slightly_smiling:
Ok ok I will post in english.

edit: it made me gain 38 characters !! :sunglasses:


Any tricks for JS? I am finding it difficult to see how someone can get down to the currently winning 49 with readline.split, even if readline is aliased to another var.

readline = 8 char
split(’ ') = 10 char
print() = 7 char
alias readline and call it twice: 5 char

That is 29 char right there, only leaves 20 char for everything else???


I believe 49 chars is a bash program wrapped in system() in JS


I confirm. The 49 characters solution in javascript is this one:

system("bash solution in 37 characters")

And it’s the same for many languages. In pure javascript i can do 66 characters.


That feels like cheating.


I know and that’s why i don’t really likes code golfing puzzles. But don’t worry, there’s many many interesting things to do on codingame :stuck_out_tongue:


@Ozzie @Magus

I fully agree with you guys, I’ll try to remove the system function tomorrow. This looks fairly easy to do but I want to test it properly before updating all the servers ;).


If you remove the system function for javascript, you must also remove it too for every languages. Java, C#, C++, C, ruby, php … All languages can execute a bash command and it is almost always shorter.

But if you do that, you’ll have to replay/reset all code for all code golfing puzzles ? It will be a huge chaos :smiley: But i like the idea.


If you do that you deserve 25 likes (one for each language)


Of course. It would be meaningless if not reset.


Is the bash version using a command line tool like awk? If so, I would argue that is cheating as well. Maybe all the solutions need to be reviewed to make sure they aren’t exploiting command line tools to do the job.


I should be able to recompute all the submissions for temperature, but its way more complex to do it to the other code golf puzzles :/.

And regarding the other languages, I don’t think that will be as easy but at least the problem will be solved for JavaScript… I have another idea of approach to deal with all the languages but we are all quite busy right now…


Bash is useless without command line tools. To answer your question, my bash version doesn’t use awk.


I agree about Bash being useless without the command line tools and I think this should not be changed, I learned a lot trying to reduce my code in Bash and the tools.

But “awk” was just an example, could be: sed, sort, tr, …

For me, just remove the system, and the ways to run system calls.


Even if I (ab)used the system() trick, I agree on disabling the possibility to run external commands (except for bash of course).

A workaround can be to clear the PATH environment variable when running the submission, to discourage the use of external commands.


That’s something I’ve tried this afternoon but the additional characters that you would have to add are still too low… If we aim at solving this problem for all languages, I’d prefer a better solution. It guess it should be possible to disable some external programs for specific languages (e.g. no grep when language != bash and no python when language = bash). But that’s not easy as easy as it sounds because the FS is shared between multiple instances used for different languages. We will keep you informed anyway.


bash should be able to use any bash command. Or it will be useless. I’m not really sure if bash should access some command like python, rb, gcc (every command that could compile and run something else than bash). But it’s not a problem for golfing puzzles. It could be a problem for the 15 puzzles achievement in bash, no big deal.

If you can disable bash commands for every langages, it will be so great.


All the submissions in Javascript have been recomputed. Solutions based on the system function no longer work.


Thanks a lot for that, is it only in javascript as of now?


Yes, because I’ve patched spidermonkey to disable the function. We still need to find a solution for every languages.