Temperature Code Golf puzzle discussion


I thought it was impossible.
Congratulation, I bow.


I really do wish there were language ratings. I managed to create an 80 character C solution, and I want to see where I stack up.


It is possible. On all our leaderboards you can click on the header to filter. Just click on the language header and select C to show only the solutions in C.


@MaximeC Yes, but this feature might be improved. The language leaderboard shows the global ranking instead of the one in selected language. So if you’re not in top 10, it’s not that easy to tell your ranking.


Best sum up ever. With that and system fully forbidden, code golf will be finally a lot of fun. :slight_smile:


ok, I found.


I have one, use a Windows machine to run all the tests: no more bash \o/


The solutions below 35 characters are impressive! I wonder if there is an algorithmic trick that I didn’t found for now, or if the solutions are hardcoded, despite the hidden test cases.
@abouvier @6pi @Origraena


About mine, it’s not an hardcoded one. Have fun :wink:


Thank you for your answer. I keep searching…


I return the question to you, your solution below 32 in Perl are hardcoded one or not?


None of my solutions is hardcoded. :slightly_smiling:
I’m still looking for (at least) 3 chars to shave off…


I can’t believe you are doing this in 36 characters in C. Do you really solve the problem as it is stated on any possible input (not just on the test and validator cases)? I mean, “main(a){scanf(”%d",&a);printf("%d",a);}" is already 39 chars… My solution is currently 93 chars, and I can believe I missed something, but I can’t believe it is feasible under less than 80 chars.


As stated above, system() is shorter than scanf()+printf(). Then there is another dirty trick to reduce it a bit more.


Thank you for your answer; indeed, I saw this after posting my question…
I agree with you and others: system() should be forbidden for these puzzles.
Still, 36 chars is impressive, and I wonder what utility you use.


I’ve made in plain C (scanf & printf, no hacking, not hardcoded) using 71 characters. Has anyone a smaller solution ?


Any tips for Perl? I see the shortest solution has 26 characters. I imagine one needs at least two "<>"s, a “print” and a “split/ /”, which gives 17 characters, leaving only 9 for the rest of the solution? This seems incredible. I wonder what I’m doing wrong :slight_smile:

The “split/ /” could perhaps be changed for some smart regex, but I really can’t see how :open_mouth:

“say” doesn’t shorten the print much as it only works as CORE::say or with a “use v5.10” line, all of which make it longer if you don’t print the trailing “\n” (which you don’t have to in this puzzle)…

Learning how to shorten these things would help me a lot when solving other puzzles so any feedback would be greatly appreciated :slight_smile:


Validator12 still failed… Seriously, I do not know what I am doing wrong…


Same for me. The 12th test case always fails. I haven’t hard coded any numbers in my code.


do you handle -0, 0 in the list ?