The Descent - Puzzle discussion

Hello,

I get the following error : “Invalid command sent. It should be an integer from 0 to 7.”

My code in Scala :

while(true) {
    val listMountainHigh = scala.collection.mutable.ListBuffer.empty[Int]
    for(i <- 0 until 8) {
        val mountainh = readInt
        listMountainHigh += mountainh
    }
    println(listMountainHigh.max)
} 

Other solution I tried :

while(true) {
    val listMountainHigh =  for(i <- 0 until 8) yield readInt
    println(listMountainHigh.max)
}

I find 9 for the max high so why the error message include only 0 to 7 ?

Thanks

You have to print the index of the highest mountain, not it’s height.

1 Like

Oh, that’s right ! :sweat_smile:
So there is no problem.
Thank you !

Help , what I need to write on javascript ?

hello, I’m having some issues with this puzzle for some reason its giving me an error saying that the closing bracket for the class declaration is unexpected here’s my code:

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

/**
 * The while loop represents the game.
 * Each iteration represents a turn of the game
 * where you are given inputs (the heights of the mountains)
 * and where you have to print an output (the index of the mountain to fire on)
 * The inputs you are given are automatically updated according to your last actions.
 **/
class Player
{
    static void Main(string[] args)
    {
        var hMax = 0;
        var iMax = 0;
        // game loop
        while (true)
        {
            
            for (int i = 0; i < 7; i++)
            {
                int mountainH = int.Parse(Console.ReadLine()); // represents the height of one mountain, from 9 to 0. Mountain heights are provided from left to right.
                if (mountainH > max) 
                {
                    hMax = mountainH;
                    imax = i;
                {
                    
            };

            // Write an action using Console.WriteLine()
            
            // To debug: Console.Error.WriteLine("Debug messages...");

             // The index of the mountain to fire on.
        }
    }
}

Check that for each opening bracket, you’ve got a closing bracket

this really is incredibly poorly explained. back to codewars for me…

Hi, just wanna share the code in Python 3 language:

admin edit: don’t share full code

I completely agree, what a mess this is on my screen. Four separate tabs all with very little explanation. To top it off they just drop you right in and expect you to know everything. This is a heaping pile of trash.

import sys
import math
while 1:
def numbers(x):
for i in range(x):
if i < 9:
i += 1
yield i
print(list(numbers(11)))

I have used a generator why it constantly display “Timeout: your program did not write to the standard output in due time.” pls help

It’s all unclear and confusing to me. This is not for beginners.

Has any-one responded to this quite reasonable request? There are some of us who do not come to this knowing what we are here to learn!

Why is it forbidden to post code? I took a MOOG course for Python, and it also would not let us post code; so i never could finish the course since I got stuck on one problem and was barred from going further. Is this some Python religious thing?

What?
It’s not forbidden, just write the interesting part of your code.

That’s why I thought it was forbidden. So, is it that we can share lines of code but not a ccomplete solution?

You can share lines of buggy codes here; the validated code is readable by people who solved the puzzle in the same language.

Well, i got some trouble to solve this one when i find codingame.

Still have some trouble, mostly because of the description of the puzzle.

Regards

How do you do the code?i
I need help!

Hey Im new to coding and would like some help on where to start, I’m working in JavaScript and understand the patterns of the heights of the mountains,
I’m unsure of how to link all the combinations into code so that the game works,
A reply would be very appreciated :slight_smile:

1 Like

i need help guys, i have no idea how to start coding in C