The Descent - Puzzle discussion


#318

Hi, can you tell me, what is wrong?

int hight = 0;
	int highest = 0;
	int highestindex = 0;

int main()
{

    // game loop
    while (1) {
        for (int i = 0; i < 8; i++) {
        if (hight > highest){
				   highestindex = i;
				   highest = hight;}
            cin >> hight; cin.ignore();
        }

        // Write an action using cout. DON'T FORGET THE "<< endl"
        // To debug: cerr << "Debug messages..." << endl;

        cout << highest << endl; // The index of the mountain to fire on.
    }
}

#319

i won’t spoil giving you the answer but only clues.

2 huge errors in your solution :

  • you are supposed to get mountain’s height before comparison.
  • you should take care that your variables have good values at each loop

#320

Hey guys,

I’m new to this site.

I read a few tutorials online for javascript beginners (functions, loops, arrays… basic stuff), wanted to try some exercices to train before I go any further. So here I am and… I’m getting so frustrated because we can’t see the solutions.

I read the exercice and I’m lost… I have no idea what to do.

After spending 20 minutes on scratching my head I finaly saw the “hints” on the left… they talk about stdin stdout stderr… Are we suppose to use these words in our solution ? (How I’m I suppose to know these? I’ve never heard of them before :frowning: )

I read the algorithm & pseudo-code which I believe is the “solution” but I have to write it down with proper code and I don’t even know where I have to write it… Is it inside the for that is already there ? or make a new one underneath ?

I tried doing things with typeof, tostring… When I write these down outside the for it says undefined (I guess it’s because of the “scope” ?) when I write it down inside the for it’s fine.

I am a complete begginer, even with the last hint I can’t understand what to do. If you guys got any hint for me… <3

(trying to do it in javascript)

Edit : Ok so I checked the answers above to get some answers, saw that I had to write the code around what’s already written… managed to complete the exercice but with no joy because I didn’t understand it on my own… feels Weird :confused: will try other exercises. <3


#321

Hi! And welcome to CodinGame :slight_smile:
Sorry that you’ve had a hard time. The first learning step here is the harder.

Maybe you can point me at what isn’t clear in the hints? I have modified them recently and I’m looking for feedback.

image


#322

Why doesn’t this work?

class Player
{
static void Main(string[] args)
{

    // game loop
    while (true)
    {
        int max = 1000;
        int number = 0;
        for (int i = 0; i < 8; i++)
        {
            int mountainH = int.Parse(Console.ReadLine()); // represents the height of one mountain.
            if (max > mountainH) {
                max = mountainH;
                number = i;
            }
        }
        Console.WriteLine(number);
    }
}

}


#323

if max is greater that mountain’s height … so you choosed to destroy the lowest mountain …?


#324

TRY THIS :wink:

[no full solution please]