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.

1 Like

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:

1 Like

@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 ;).

8 Likes

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.

2 Likes

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

1 Like

Of course. It would be meaningless if not reset.

1 Like

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.

1 Like

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.

1 Like

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.

4 Likes

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.