Temperature Code Golf puzzle discussion


#62

@Plopx
36!
I thought it was impossible.
Congratulation, I bow.


#63

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.


#64

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.


#65

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


#66

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


#67

ok, I found.


#68

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


#69

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


#70

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


#71

Thank you for your answer. I keep searching…


#72

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


#73

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


#74

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.


#75

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


#76

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.


#77

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


#78

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:


#79

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


#80

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


#81

do you handle -0, 0 in the list ?