The Descent - Puzzle discussion

Hi everyone, newcomer here.

I tried this puzzle in Lua.
I had the exact same solution but with other variable names and it didn’t work (highestMountainH instead of max and highestMountainID instead of imax).

After some name replacements attempts and copy pasting, I found out that I can use whatever name I want for imax, but I have to use max otherwise it won’t work.

Do we have to use the variable names of the solution ?
Is that standard behaviour for all puzzles ?
How are we supposed to know which name was used ? Only mountainH was mentioned in the constraints.

Thank you in advance for your help!

EDIT: ok, half an hour later, I reloaded the page, and now it works!
I used ctrl-z and came back to the exact same code I had and it doesn’t produce errors.
Not too sure what happened.

Did you sneaky devs quickly fix it ? :wink:

I have tried C++ test and found it irrelevant since the compiler version is quite old - 4.9

Thank you !

A l’aide SVP je sais pas comment réussir si un personne peut m’aider svp mrc

I could use some help… I don’t know how to sole this in java script except the order of mountains to fire at but when i do that the mountains change so my order doesn’t work. Can a expert help a noob out please? If anybody is listening i need the help!

Hi! I begin now to learn about coding, but I haven’t any basis. Is there somewhere a easy introduction to the langage of Javascript?? I couldn’t even understand what i, i++ or even parseInt() should mean. :confounded:

You should read some documentation, like the basis of this language.

1 Like

Hi! Is this site for professionals or it’s a learning site? I’m beginer and I totaly do not understand how to solve this puzzle. What commands should I know?

With what language are you trying to solve this puzzle?

With Python!

OK, so find a Python tutorial somewhere before trying to solve puzzles. :wink:
You have to read the input then print on the standard output your answer in order to destroy a mountain without being killed.

2 Likes

Hello, I am a beginner at Java and I was trying to solve this puzzle.

I got passed the descending mountains. However, once I get to the scattered mountains I am clueless.
I tried that provided solution but it doesn’t work either. This is what I have

        int hmax = 0;
        int imax = 0;
        
    // game loop
    while (true) {
        for (int i = 0; i < 8; i++) {
            
            int mountainH = in.nextInt(); // represents the height of one mountain.
            
            if( mountainH > hmax){
                hmax =- mountainH;
                imax =+ i;
            } 

The solution does not have hmax=- mountainH. When I try it without the subtraction sign not even the descending mountains test case works. Any help would be appreciated!

You need to reset hmax et imax each turn

can you please explain? I’ve tried looking up what you mean and come up empty handed

You define imax and hmax ONE time for the first turn. So after reading the inputs, you set imax/hmax to the biggest moutain and fire it properly.

Since you don’t reset imax/hmax after firing (or before reading new input), you’ll keep firing the same mountain even if it’s not the biggest mountain anymore.

1 Like

Terrible explanation of input and terrible explanation of what you have to do.

Hi, so I have a few questions on the first puzzle in c++, it goes, “for i = 0, i < 8, i++”
why isnt i initialized, what is i++?
I get that i is somehow the mountain that I am currently getting a cin for height of but, what?

why can’t i initialize the variables for highest mountain and which mountain to fire on outside of the while loop?

this is what i had:

    using System;
    using System.Linq;
    using System.IO;
    using System.Text;
    using System.Collections;
    using System.Collections.Generic;

    class Player
    {
        static void Main(string[] args)
        {
            int HighestMountainHeight = 0;
            int MountainToFire = 0;

            while (true)
            {
                for (int i = 0; i < 8; i++)
                {
                    int mountainH = int.Parse(Console.ReadLine()); // represents the height of one mountain.
                    if (mountainH > HighestMountainHeight)
                    {
                        HighestMountainHeight = mountainH;
                        MountainToFire = i;
                    }
                }
                Console.WriteLine(MountainToFire); // The index of the mountain to fire on.
            }
        }
    }

Your two init lines are not well placed.

First iteration of the loop, you find the highest mountain right?
Once you’ve found it, you save the height.
On the second iteration, all mountains have the same height as during the first iteration but one (the previous highest one that you shot). So, what happens with this condition:

if (mountainH > HighestMountainHeight) ?

It’s never true. Because no current mountain is higher than the previous higher mountain. Do you understand the issue?