/** * Auto-generated code below aims at helping you parse * the standard input according to the problem statement. **/ var n = parseInt(readline()); // the number of temperatures to analyse var temps = readline(); // the n temperatures expressed as integers ranging from -273 to 5526 var b = function(a){ return Math.abs(a); } var closest = temps.split(" ").reduce((p,c)=>(b(p)===b(c))?(p<c)?c:p:(b(c-0)<b(p-0)?c:p)); // Write an action using print() // To debug: printErr('Debug messages...'); print((closest) ? closest : 0);
Dominic Myers writes about all sorts of stuff to do with HTML, CSS, JavaScript and a fair chunk of self-indulgent stuff. Thoughts and opinions are all his own, and nothing to do with any employer.
Tuesday, 18 October 2016
Fun little challenge (Temperatures closest to 0)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment