Kirk's Quest - The Descent - puzzle discussion (old)

In my case, I ask to shoot when I pass the same position, the first and second case everything works fine but in the next, supposedly shot but nothing happens.
EDIT:
When i add if-else statement part of the problem is solved. But i don’t understanding why?

I don’t understand the fact that we have to hit once a round which is 8 passes while we cannot possibly choose our mountain at a specific basis.

Because it’s the game’s rule?

For two days I can’t solve it.I don’t understand. Why it doesn’t fire when MH:9 i:3 SX:3? Help, please.

EDIT MOD: Nope. Read above, and the FAQ, don’t post your full code, explain your problem etc

I’m sorry. I stocked each MH in an array.

if(MH[i]!=0 & SX==i)

I wrote debugg massage. It must shoot when MH=9 i=3 SX=3 but it don’t. And I don’t understand why.

You need to print a action ( FIRE or HOLD) only once per turn (while-loop)

1 Like

Are the MHs entered after each pass?

Yes, they are.

I don’t know. Is it a mistake in task? This morning, when I was solving it spaceX and spaceY variables were the SX and SY and the task worked normally. A man, who changed it, look at the horizontal coordinate of ship with debugging massage. It’s 0, 1, 2, 3, 4, 5, 6, 7, 7 (ship avove mountain 7 and directed to the right) then 6, 5, 4, 3, 2, 1, 0, 0, 1 (still above mountain 0).
P.S. Sorry for my poor english.
P.P.S. I liked it more when it was SX, SY, MH. It’s more easy and concisely IMHO :slight_smile:

I do not understand how to access the heights of individual mountains. Insight would be welcome.

The for-loop will give you each mountain heights (MH)

Thank you! Solved!

I understand this, but I cannot figure out how to find the height of a specific mountain.

It’s in the ordered input.

With this code doesn’t working, I don’t know why… It gives FIRE but doesn’t make it.
            if(mountainH != 0 && mountainH == spaceY - 1 && i == spaceX)
                printf(“FIRE\n”);

Two mountains with equal heights… should be fired before you are just above one of them.

Hello there :slight_smile: I have a problem with doing this exercise.I have in for loop if and if else statement which resolve which mountain is the highest.its looking like this

(for loop)
if mh[i] == 9
h = i
else if mh == 8
h = i
…and so on.and, outside for loop, there is logic for moving my ship ( if spacex > h then hold) and so, but i dont know why, when i have mountain with 9 height and mountain with 6 height which is further, the spaceship just go after the highest mountain to destroy this smaller mountain, and of course it crashes on return.Any help?

why not store the highest value like this

max = 0
for loop
  if mh[i] < max
    max = mh[i]

what if your ship is on the wrong side and spacex < h (ex: spacex = 2 and h = 5), it won’t work, the logical operator you’re looking for is != which means ‘different than’ and is the opposite of == which means ‘equals to’

I officially give up. I’m doing this in Javascript and I cannot figure it out. Moreover, the modulo doesn’t appear to work and variable values are out of whack. For example,

printErr(spaceY);
    if (spaceY === 10) {
        print(“FIRE”);
    } else {
        print(“HOLD”);
    };

That correctly prints out the value for spaceY as 10, 9, 8 etc. But it will always fire, regardless of the value of spaceY. And if I set it the if statement to only fire if spaceY equals anything but 10, it will NEVER fire.

SpaceY is useless as f**k for this puzzle anyway. :smiley:

You need to find the hightest moutains then fire when you’re above