So new to programming and a little confused I thought the input was random or a list that is changed to an int but apparently its always the same number ?
I tried using max function to do the program but that didnt work since it doesnt give me a list.
I just need someone to confirm the input never changes and its a single integer its not a list ?
If that is the case then what about the list of mountains in the screen is there a way to get that to use as info or would that for some reason be considered cheating ?
If the inputs do not give you a list, you may program to create a list yourself
The list of mountains in the screen for a test case is valid for that particular test case only. If you hardcode the values in your program, you wonât pass the hidden validators (which are used to verify your submitted code), because the validators are different from the test cases.
I didnt want to hardcore those specific values. I was wondering if there was some way I could cause the program to read from or get the input values from whats printed for the mountain values if thats possible ? So that it could be used in any of the descent games.
The default code you got when you first started the puzzle helps you read the inputs. So, you write additional code to either process the inputs right away, or store them somewhere before processing them.
Hi, im totally new to coding in general. I dont get While 1:
what does 1 mean? and also the hints tab, suggest these variables:
max
imax
what are these stands for?
While 1 means âWhile Trueâ, i.e. the loop is repeated for ever (unless something inside the loop breaks out of it).
In the pseudocode, the variables âmaxâ and âimaxâ are set up to store some values. Can you see what values will eventually go to âmaxâ and âimaxâ?
I have tried the below code but it doesnât work it stops at the montain with index = 1, I tried to put the index of the montagnes already destroyed in a list in order to avoid to fire on them again.
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int hmax=0;
int imax=-1;
ArrayList<Integer> listDeMontagneDetruit = new ArrayList<Integer>();
while (true) {
for (int i = imax ; i < 8; i++) {
int mountainH = in.nextInt(); // represents the height of one mountain.
{
if (mountainH>hmax && !(listDeMontagneDetruit.contains(imax)))
imax = i;
listDeMontagneDetruit.add(imax);
}
}
System.out.println(imax); // The index of the mountain to fire on
}
}
@tarekbel2d: Youâre overthinking it. You donât need to keep track of anything to solve this one. You just need to decide on each turn which mountain is currently the highest. (You also have a variable there that never gets updated.)
[Python]
Can someone PLEASE tell me what in the hell is going on in the code? My brain just BREAKS!
This is ridiculous and frustrating.
The web page never mentioned âHeight of mountain 0 : xâ yet, these lines get printed.
I see no such code in the code. Why is is appearing in the console output?
There is a comment in the code:
# To debug: print >> sys.stderr, âDebug messagesâŚâ
What does this mean? If I simply enter that in the editor, it doesnât output any useful information.
What am I suppose to do with that code?
The info on the left says âinput for one game turnâ but Iâm the one whoâs suppose to provide input to the game, right? Why is the input already given?
Also, on the input, it says iâm given 8 LINES with mountainH. How am I suppose to interpret this info? am I getting eight times mountainH as a given?
On the out put it says âsingle line of integerâ while in the code editor, the integer is between quotes, so doesnât that make it a string?
Can someone help me? I realize I sound like a retard but I canât make heads or tails out of this and I WANT to like this website and the problems. HELP please.
Thanks
Reading your profile, I see that youâve already passed 100% of the game, and also 100% of Temperatures, so I assume youâve got no further questions now.
But in case you donât understand the interface of the website, I suggest you go through the Onboarding puzzle again.
The onboarding doesnât really clarify that either. I just moronâd my way through.
Whatâd Iâd love to see is an actual, literal explanation of whatâs going on in the interface. Which pieces of data are delivered by the game and what my options are to do with it.
For example, it took me months to figure out that the âinputsâ were being done by the server.
I donât know if I can explain it any more clearly than that.
At least I seem to be making progress with the puzzles, so there is that.
iam also having the same doubt.you know means pls tell me.first conditon only gets passed other may get failed how the loop works i dont no.pls help me
Hi guys, Iâm a beginner and iâm trying really hard to understand this but struggling. Iâm doing it in Python3 cause thats the first language iâm learning.
Iâve got a few questions:
mountain_h = int(input()) # i donât get how that works. From what i know, input asks the user for input from the keyboard, but once you submit or run the program, there is no input prompt asking you to enter anything. How is this finding and storing the height of the mountain?
What does it mean by game turn? Is that the same as one time around the while loop?
Correct me if im wrong, but you shoot by printing the number of the mountain you want to shoot? So the loop has to find the heights of each individual mountain, then decide which mountain is the tallest, and if itâs, say, number 5, it will result in print(â5â)? Is that how the solution goes?
No idea why the hell this doesnât work. Iâve pumped it into a repl that mimics the codingame env, and the results are exactly as expected, but for some reason it simply will not work here. I cannot for the life of me figure out why⌠And yes, Iâve tried using Math.max.apply(null, arr) as well, to no avail.
while (true) {
for (var i = 0; i < 8; i++) {
var mountainH = parseInt(readline()); // represents the height of one mountain.
var height = [];
height.push(mountainH);
var maxHeight = Math.max(...height);
var target = height.indexOf(maxHeight);
print(target);
}
}
EDIT - Interesting observation: When printErr the max of any array I supply the IDE, it will ALWAYS print the entire array, never the max value of the array as expected. I think there may be something wrong with array functions hereâŚ