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 ?
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,
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
Actually, this is my exact code⊠that pseudocode was incorrect; I donât know what I was thinkingâŠ
if (temps.isEmpty()) { System.out.println("0"); } else { int closestPositive = 5526; int closestNegative = -273; Scanner tempString = new Scanner(temps); // Write an action using System.out.println() // To debug: System.err.println("Debug messages..."); while(tempString.hasNext()) { int tempInt = tempString.nextInt(); if(tempInt < 0) { if(tempInt >= closestNegative) { closestNegative = tempInt; } } else if(tempInt > 0) { if(tempInt <= closestPositive) { closestPositive = tempInt; } } }
bonjour je suis en Java
Pour le 2Ăšme test jâobtient bien
-12
-5
-1337
-12
Ceci dit malgrĂ© que tout les autres test fonctionne pour celui ci il me trouve -1 ( qui viendrait du -12 je pense âŠ)
jâutilise
String[] tab = temps.split(" ");
puis
int val = Integer.parseInt(tab[i]);
pour la récupération de la chaine
someone helps me please!! i canât take the numbers from the vector of char⊠i tried with sscanf but it always begin from the beginning of temps and it returns me only the first valueâŠ
I think someone has posted about this above but as my french is terrible I cant be sure XD I have noticed that the second test case has an integer with the value if â-1337â but the problem statement makes it clear that the lowest a number should go is â-274â. Just thought I should let someone know. @SaiksyApo maybe?
Problem solved
Bonjour,
Je ne comprends pas ce quâil faut faire pour les validateurs : " -273 alone et 5526 alone". Quelquâun pourrait me dire ce qui est demandĂ©?
Merci