Temperatures puzzle discussion

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.

1 Like

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? :wink:

1 Like

Problem solved :slight_smile:

1 Like

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 :slight_smile: