same for me. 12th doesn't work.
I wonder if there is any trick to shorten the part of the code where you calculate the temperature closest to zero.
I am using C for this challenge. Currently, for me, that part of code is 26 characters long (excluding the semicolon) including the ternary operator.
Maybe there is a way to find the temperature closest to zero by using bitwise operators? I have found a way to avoid utilising math functions (from the math library) to calculate it, but apart from that, I can't think of anything else.
This is from my own experience. My best attempt with C, that does not do the "system" cheat, turned out to be 71 characters long in total. In this code, the "closest to zero and preferredly positive" check is 13 characters long. This consists basic C operations and no bitwise. Tip: one does not have to compare absolute values when in need of comparing by absolute values.
Thanks for the reply.
I have not used the abs() function in my code, but like you said, I did compare absolute values without using abs() before finding a way to use basic operations to do the check to make my code shorter. (Now that part of the code is 21 characters long and has 2 ternary operators.
Apart from this, is there a shorter way to get inputs other than using the scanf's return value? I currently use 1 printf for outputting the value closest to zero and 2 scanf's.
You are welcome!
I do not think that there is alternative and shorter ways than scanf and printf. 'Scanf' because input is a string, but the comparisons have to be numerical. 'Printf' because one has to output the numerical answer as a string. I have not found the way to do this with fewer number of characters. But concider this - it could be that the number of characters in code can be cut down by using some of the functions less times.
All right. Maybe I only need 1 scanf, but until I find a way to shorten my code, I am stuck at 90 characters total.
(The checking part of my code is now 19 characters long.)
I was stuck on it for one year too but I finally figured out a special case that is indeed legitimate to test: it's about the bold part of the rules. Actually it's harder to understand properly in French.
Please, add more validators to avoid hardcoded solutions
I don't think there's a lot of hardcoded solutions on temperature. There's already a lot of validators.
Getting around the validators is part of the fun here. Otherwise anarchy golf is a better platform.
Same to me.