my code broke on just the first case. I tried changing it around but I was never able to get as far. I need the temp to compare numbers so it’s not just checking if t is less then inputs[t+1].
my nested if statement checks if temp is greater than t. if so then it will turn it into t.
if (curretNum is less than nextNum)
check if (assumedAnswer is greater than currentNum)
if true change assumedAnswer to currentNum
on the simple test I had the problem that it was checking if t is less than the inputs[t+1] then changing it to t so in 1 -2 -8 4 5 it would out put -2 or 4 because the absolute value of 1 is less than 2 but not 8 and 4 is in fact less than 5
i’ll continue seeing if I can make temp better. or fix up my logic but so far I can’t get rid of it due to it being my best solution
I solved this in Clojure, but unfortunately the boilerplate code provided for reading stdin for the test cases results in a NumberFormatException because the call to Java’s Integer/parseInt cannot handle the empty string for test case 6.
enfin j’ai réussi à résoudre le puzzle c’était facile mais j’etait pieger avec scanf de la valeur de n après la condition
finally I managed to solve the puzzle it was easy but I was trapped with scanf of the value of n after the condition
Hello, i have an issue with this challenge. I’ve written my code with python but every time I’m running the test cases they all failed but when I tried on my IDE(Pycharm), I got the right answers of the test cases. Dunno how you could help me. Thank you!
Some of the possible reasons are that your code times out (because Codingame specifies a time limit for your code to produce the answers), or your code does not output the answer in the required format here.
What errors does the console show here when your code fails?
Hello i’m a newbie, i compiled my code with g++ on linux mint and the test case with single value -273 and 5526 works fine on my IDE at home.
I am flummoxed however that when I submit my code to the Codingame platform, there is an error message for those 2 particular cases.
I will send my code to the IDE since I would really like to understand why there is a difference in the results. Thanks for any advice or help you can proffer.
Leish
Hey I hope you are well. So I attempted the question and got it right but wanted to try a different method. Please see below. It did not test correctly, is there any tips on how to fix it?
class Program
{
static void Main(string[] args)
{
int[] inputs = new int[] { -230, -20, -10, -100, 20000, 100, 5, 95, 32, -30 };
int closest = inputs[0];
for (int i = 1; i < inputs.Length; i++) {
int t = inputs[i];
if (Math.Abs(closest) > Math.Abs(t))
closest = t;
}
Console.WriteLine(closest);
}
}
Hello, I did the test in php on my IDE and everything is fine. Except on the IDE of codingame the identical positive and negative temperatures are not validated.
An idea? here is my piece of code.