It seems that the last test case is failing unpredictably even when given the correct answer. I’ve seen it on my own solutions that used to pass and others have as well.
I saw it in javascript and python and I heard it reported that C# is a problem (though I did not see it myself). For C#, outputting a string “0” instead of a variable equal to 0 sometimes causes it to pass, and sometimes not.
I have the problem for this puzzle too.
I use Java as a language, and I ended up with a lambda which does the job Optional<Integer> i = Arrays.stream(temps.split(" ")).filter(s -> s != null && s != "") .mapToInt(Integer::decode).boxed() .min(Comparator.<Integer>comparingInt(Math::abs).thenComparing(Comparator.<Integer>reverseOrder()));
Unfortunatly only 5 of the 6 tests pass, while the 6th raises an exception (which it doesn’t when run in Eclipse):
Exception in thread "main" java.lang.NumberFormatException: Zero length string
at java.lang.Integer.decode on line 1162
at java.util.stream.ReferencePipeline$4$1.accept on line 210
at java.util.Spliterators$ArraySpliterator.forEachRemaining on line 948
at java.util.stream.AbstractPipeline.copyInto on line 481
at java.util.stream.AbstractPipeline.wrapAndCopyInto on line 471
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential on line 708
at java.util.stream.AbstractPipeline.evaluate on line 234
at java.util.stream.ReferencePipeline.reduce on line 479
at java.util.stream.ReferencePipeline.min on line 520
at Solution.main on line 19
Hi I am having this same problem in JavaScript. When I consol.log(‘0’) the failure response is: Found: undefined… Expected: Nothing. And if I were to consol.log(‘zero’) the response is: Found: zero… Expected: 0
That means you’re correctly printing out 0, but also something else after it.
Your solution needs to output exactly what’s expected, nothing less nothing more.
I tried to write only: console.log(0)
in the last test and it works, so as said above, the problem doesn’t come from here, you print an extra output somehow.