The Descent - Puzzle discussion

Hi Metallized,

The 8 mountains have no name. If you want you can call them Mountain0 - Mountain7.

At each turn, aka at the beginning of while(1) loop, the system provides you 8 numbers, representing the heights of 8 mountains. You need to scanf() 8x times to read all values.
Then you use your algorithm to select 1 of them to shoot.
Then we finish this turn, and go back to beginning of while(1) again. The system provides 8 new numbers.

The point in my initial post was, we must do 8x scanf() all the time, even if we don’t need all 8 numbers in the algorithm. Otherwise, the un-read numbers will still be there in the next round.

1 Like

I have a Question, in JS:

const mountainH = parseInt(readline());

I don’t understund this line. Means that readline is equal to the previous for loop? and parseInt is converted it into a Integer?

Did you check the hints on the left of the IDE? The CodinGame system works with Standard Input and Output streams. readline reads the next line in the data sent by CodinGame in the Input stream.

Hi, the start of the program in Scala is already the solution. It really gets too easy :slight_smile:

We provide the default code to read the inputs in every puzzle and for every language. The Scala default code doesn’t solve the puzzle

1 Like

Hi, sorry for the inconvenience, I found my error, I tested Condingame Sync and it gave me the solution when I reset.
Have a good day.

no worries :wink:

Hello,

I’m trying to use C# to solve the puzzle. If I don’t touch the code at the begining, the ship doesn’t move and end up exploding. When I try other langage, the ship move and is destroyed when it meet a mountain. Did you ever had this kind of bug?

Default code outputs a hardcoded answer each turn, to allow you to better understand the desired output format. It will not solve the problem, you have to use the inputs to provide the correct output.

1 Like

I found with Decent when i tried coding loops it just spat errors back at me. I don’t know if it’s just that I am rusty at c++ or if that’s just the way it handles loops. I was only able to get a for loop to work properly with it. aside from that it wouldn’t let me use repeat, and it wouldn’t let me use number sorting with an array, so I found myself in frustration just running the same cout command 8 times over, which I know isn’t what it is looking for.

Having a for-loop to work is good enough to solve it.

“repeat” is not a keyword in c++. No surprise it causes errors.
c++ does not know how to sort an array unless you included suitable library in header (or write a sort function by yourself) to help it to sort.

1 Like

I’m a newcomer. So, would you mind telling me why we must use English to communicate ? Other languages are prohibited here?

It is off-topic so make it brief.

  • English is the most common international language.
  • The owner/management of CG, I guess, may want this platform be international-oriented rather than a single nation oriented.
    so comes this policy.

Besides English, you can communicate in C, C++, python, java, javascript…dozens of options to choose. But you know, all programming languages are having keywords based on English.

Extra notes: you can join Discord to chat, where there are channels in fr and ru

1 Like

Help me please! With input: 9,8,7,3,6,5,2,4.
My code:

On step 3/5 (Input:0,0,0,3,6,5,2,4) it fires on the mountain 3, in spite of value of maxI is 4. Thank you!

You should use cout only once per turn, otherwise you are out of synch with the game’s referee.

1 Like

im new to coding what is the best way to learn all of this

Hello @Darkraven135 !
If you are a complete beginner, even the simplest puzzles of the site may be a little hard. The best would be to learn at least the bases (Variables, conditions, loops…) and then start trying the puzzles.
What language do you want to learn ? (If you know)

im up for any language

To made it simple, you have two possibilities:

  • High-level languages : They offer an abstraction level which allow you to bypass some difficulties like the memory management, or the variable typing for example.
  • Low-level languages: They let you manage all of the stuff.
    You will probably get faster satisfying results with a high-level one, but a low-level language will give you a better understanding of a lot of notions.

The choice depend of what you want to do with your future coding skills ! And of your preference of course. ^^
Here some suggestions:

  • C (Low-level): Probably the best language to start with, if you want to understand “how it work inside”, but not the simplest one.
  • C++(Low-level): Based on C, it offers a lot of practical tools, and is “Object Oriented”, in contrary to C.
  • Python3(High-level): Perfect if you want to start fast. This language allow you to do complex things easily, and has tools for everything. On the other hand, this is not the good choice if you want a real comprehension of what you do.
    Others could probably give you a different list, but this one is a good start. :wink:
1 Like

Thank you and i will get started on it