System.Linq.Enumerable+c__Iterator10`2[System.String,System.Int32]
got this error if i want to view it
System.Linq.Enumerable+c__Iterator10`2[System.String,System.Int32]
got this error if i want to view it
Since itâs an array you have to do a foreach to see the content.
foreach (int i in array)
Console.Error.WriteLine(i);
ok got itâŚ
Cant i use array[i] ?
Yes you can but you need to convert it to a list with .ToList();
Un problème que jâai et qui est rĂŠcurrent sur tout les puzzles proposĂŠ sur codingame et que je ne connait pas le type des input.
temps est-il une liste ?
Ce ne sont que des chaĂŽnes de caractères, les entrĂŠes nâont pas de type particulier.
Il semble y avoir un problème avec le 2ième test en PHP.
Tous les autres tests passent, et pour ce test particulier jâĂŠcris bien â-5â (la rĂŠponse qui est attendue", mais jâai droit Ă un:
Echec
TrouvĂŠ : Rien
Attendu : Rien
Et quand je soumets, les validateur passent tous
Es tu sur de ne pas avoir un caractère invisible à la fin de ta chaine ?
Hello, above is my source code for this given problem.
The goal is to analyze records of temperature to find the closest to zero.
As you can see in the comments, how I was looking to solve the problem is read the data of integers stored in that string variable.
Then, separate them to find a minimum positive number and greatest negative number, then choose the one closest to 0.
Hi,
You have to use cerr to print debug message.
Then :
integers ranging from -273 to **5526**You have to comment your debugs, or use âcerrâ instead of âcoutâ to show them. (debugs: found, pmin, nmax)
And for the last test (0), you have to change your code to check this âspecialâ case.
Ce problème sâappelle recherche dans une liste mais ce nâest pas une liste qui est fourni mais une chaine de caractère quâil faut sâefforcer de convertir en liste ⌠sans savoir comment est cette fameuse chaine.
Hi, I changed to above but still gave me the same error. I think i followed the requirement, and canât really move forward.
Use cout to print output (and cerr for debug only)
cout << result << endl; //1
Then define your if(n == 0) result 0 outside the loop, because you overwrite result some line after the for-loopâŚ
Thanks! It worked now, and output matched.
Now i will move on to fix algorithm for case â0â.
Hi,
Working on the puzzle with Javascript. I am having difficulty accessing the âtempsâ variable. Itâs not in an array, and when I try to split it:
var n = parseInt(readline());
var temps = parseInt(readline());
var test = temps.split(â ');
I get the following error:
TypeError: temps.split is not a function
at Answer.js.null on line 8
If itâs not an array and itâs not a string, Iâm not sure how I can access the data. I tried printing the âtempsâ variable to see if it shed any light, but doing so only resulted in one number:
print(temps);
Standard Output Stream:
1
Any suggestions?
use parseInt after split, not before.
That did it! Thanks magaiti.
Hey everyone, I am having trouble finding the best way to create Int variables to hold ints closestPositive and closestNegative. I am currently instantiating them with the constraints provided in the instructions, but my score is being marked down slightly for hard-coding the values.
int closestPositive = 5526;
int closestNegative = -273;
compare these against all values in the string
if newValue > 0 && newValue < 5526
closestPositive = newValue
etc.
But apparently I canât declare a value for those variables myselfâŚ
I tried creating them in the loop, but the scope doesnât reach the out statement at the end of the calculation.
Suggestions?
Is this your code in the loop? why do you compare to 5526 again? newValue < 5526 will be true for all values
=> you override closestPositive every time and at the end it will be just the last value in the input