Temperature Code Golf puzzle discussion


#82

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


#83

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


#84

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 !


#85

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.


#86

Maybe your function fails on a -5 5 case.


#87

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


#88

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:


#89

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


#90

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.


#91

Real Python or a system-like cheat?


#92

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.


#93

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


#94

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


#95

Same, problem with 12th validator test…


#96

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


#97

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:


#98

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


#99

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

#100

Ok, I think I understand :wink:


#101

Hi, any clue about the Validator 7 in javascript ?