Temperature Code Golf puzzle discussion

What should return [’-0’, ‘0’] if not 0 ?

Same here, the 12th failed and I don’t find why. Anyone could give us a hint ?

I’ve found two tests that make my code fails (miserably) :slight_smile:

First :
2
13 -11

Second :
2
11 -11

I hope that helps !

1 Like

I have done this on scala and python and both uses anonymous functions (lambda) and they fail on 12th test. It would be really nice to know what is the 12th test doing / testing. Without lambda, I can pass the test.

Maybe your function fails on a -5 5 case.

Also check the case where there is only one null temperature: “1\n0”. The answer is “0”.

oh no! My bad! sorry for the trouble and thank you all for the help. I had a bug in my code. Shorting too much plus own code -> impossible to see own mistakes.

The case was 5 -4 and -4 5 gave me different answer. Why I couldn’t see that coming… :smiley:

Hmm. It appears that Python one-liners are possible :slight_smile:

Damn, I’m stuck at 39 in Bash. The main character-eating issue for me is the last test, where you have to make it 0 if there are no inputs. Maybe there’s someway to combine the first line with the rest of the lines, because the first one is 0 when the answer should be 0, which would get rid of number conversion and the initial read in one go. But I don’t know how I would go about that.

Real Python or a system-like cheat?

I certainly hope that it is real Python! ‘system’ directive is not needed. I tried to shave off some more characters, but it seems that I am not as skilled as some other players who got the length of their Python code down, even to the mysterious 53 characters.

My best solution in Perl (31chars) use a bit of perl and a system call…

do you havy any tips for making it shorter in Bash? I have 39 chars. Do you have to make any perl call?

1 Like

Same, problem with 12th validator test…

There’s no perl invocation in my bash code (the reverse is not true, though).

Idem, no perl invocation in my bash (the reverse is not true too). If it’s not already the case, keep only the first line take only 4 chars + the pipe one.
@Plopx congratulation for your 28 chars :dizzy_face:

@Plopx Do you really do a 6chars system call in C?!

Nothing special there: 17 chars without parameter for system(). For the rest, it depends on your definition of “char” :wink:

$ LC_CTYPE=en_US.utf8 wc -mc temp.c
34 62 temp.c

Ok, I think I understand :wink:

Hi, any clue about the Validator 7 in javascript ?

1 Like