The Descent - Puzzle discussion


#213

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 ?


#214

If the inputs do not give you a list, you may program to create a list yourself :wink:

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.


#215

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.


#216

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.


#217

ah alright thanks for the info.


#218

Man, I wish they would add HTML to the roster of other codes. That would be so nice.


#219

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?


#220

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”?


#221

Hi,

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.

Any comment is welcom.

import java.util.;
import java.io.
;
import java.math.*;

/**

class Player {

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
    }
}

}


#222
  1. Please don’t post full code on this forum.

  2. It may not be correct for the “for” loop to start with “i = imax”.

  3. Please make use of the “System.err.println” syntax to print out your variables to help you debug your code.


#223

@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.)


#225

[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


#226

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.


#227

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.


#228

Hi i am quite lost solving this puzzle could you help me !


#229

what is the solutioon for this


#230

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


#231

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?

Appreciate any advice, thanks guys.


#232

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…


#233

you need to print an output once per iteration of the while loop, else your code gets out of synch with the input/output stream.

Also, you probably want to do the max of the heights once you’ve read all of them in your for loop. I hope it helps.