Thank you, however I really hope this gets fixed soon because it’s still frustrating to resubmit in order to get full score! Keep up the good work.
I understand how frustrating it can be! This should be fixed now :). If that happens again, please let me know. Thank you.
e.g.
printErr(typeof mountainH)
There is a mistake in the comment for the Go code.
It refers to a “while loop” (I guess this is a generic comment for all languages), but Go doesn’t have “while”. Instead, it’s wrapped in a “for” without a condition which is Go’s equivalent. This is pretty hard to spot if you are trying to learn Go! I had to switch to Bash and back to see what was actually going on.
I think there is a bug in test case no 4.
targeting a mountain even there is no mountain
Game information:
Let’s destroy those mountains to secure our landing…
Height of mountain 0 : 0
Height of mountain 1 : 6
Height of mountain 2 : 0
Height of mountain 3 : 5
Height of mountain 4 : 0
Height of mountain 5 : 8
Height of mountain 6 : 0
Height of mountain 7 : 6
1
8
Standard Output Stream:
5
Game information:
Your spaceship targeted mountain 5, your altitude is now 9
Height of mountain 0 : 0
Height of mountain 1 : 6
Height of mountain 2 : 0
Height of mountain 3 : 5
Height of mountain 4 : 0
Height of mountain 5 : 5
Height of mountain 6 : 0
Height of mountain 7 : 6
2
8
Standard Output Stream:
7
Game information:
Your spaceship targeted mountain 7, your altitude is now 8
Height of mountain 0 : 0
Height of mountain 1 : 6
Height of mountain 2 : 0
Height of mountain 3 : 5
Height of mountain 4 : 0
Height of mountain 5 : 5
Height of mountain 6 : 0
Height of mountain 7 : 0
3
8
Standard Output Stream:
1
Game information:
Your spaceship targeted mountain 1, your altitude is now 7
BOOOOMM!! Nice Shot!
Height of mountain 0 : 0
Height of mountain 1 : 4
Height of mountain 2 : 0
Height of mountain 3 : 5
Height of mountain 4 : 0
Height of mountain 5 : 5
Height of mountain 6 : 0
Height of mountain 7 : 0
4
8
Standard Output Stream:
3
Game information:
Your spaceship targeted mountain 3, your altitude is now 6
Height of mountain 0 : 0
Height of mountain 1 : 4
Height of mountain 2 : 0
Height of mountain 3 : 2
Height of mountain 4 : 0
Height of mountain 5 : 5
Height of mountain 6 : 0
Height of mountain 7 : 0
5
8
Standard Output Stream:
5
Game information:
Your spaceship targeted mountain 5, your altitude is now 5
Height of mountain 0 : 0
Height of mountain 1 : 4
Height of mountain 2 : 0
Height of mountain 3 : 2
Height of mountain 4 : 0
Height of mountain 5 : 0
Height of mountain 6 : 0
Height of mountain 7 : 0
6
8
Standard Output Stream:
5
Game information:
Your spaceship targeted mountain 5, your altitude is now 4
Height of mountain 0 : 0
Height of mountain 1 : 4
Height of mountain 2 : 0
Height of mountain 3 : 2
Height of mountain 4 : 0
Height of mountain 5 : 0
Height of mountain 6 : 0
Height of mountain 7 : 0
7
8
Standard Output Stream:
1
Game information:
You crashed your spaceship on mountain 1
Height of mountain 0 : 0
Height of mountain 1 : 4
Height of mountain 2 : 0
Height of mountain 3 : 2
Height of mountain 4 : 0
Height of mountain 5 : 0
Height of mountain 6 : 0
Height of mountain 7 : 0
I think that there is no bug.
Your code seems faulty.
Hello everebody,i would like to ask(in Java) about this --> int mountain = n.nextInt(); who gives the values?it not supposed to be me?
2)Is there a way to fire anytime you want or to go up and down?
OK it work for me like this
while (true) {
for (int i = 0; i < 8; i++) {
int mountainH = in.nextInt(); // represents the height of one mountain.
System.out.println(i);
}
But still wondering about that nextInt();
I think you only have to use print() rather than printf().
It’s the input stream. It gives you the height of each mountain. You can consider it like parameters of a function.
Each turn your ship goes down. Each turn you can fire only once with the output stream. A turn corresponds to one iteration of the while loop.
i cant understand what i must do and there is no solution i can acces. how is this supossed to be fun?!
Sure there’s a solution you can access:
Click Hints -> 03 SOLUTION
This will show you a solution for The Descent in your chosen language.
- danBhentschel
Python 3 solution here.
Works on all rounds except for strong mountains 2 (test case 4)
game loop
while True:
mountain_heights = []
result_dictionary = {}
for i in range(8):
mountain_h = int(input())
mountain_heights.append(mountain_h)
result_dictionary[i] = mountain_h
for key, value in result_dictionary.items():
if value == max(mountain_heights):
print(key)
The issue is that after the 4th loop, the mountain range looks likes this:
Height of mountain 0 : 0
Height of mountain 1 : 4
Height of mountain 2 : 0
Height of mountain 3 : 5
Height of mountain 4 : 0
Height of mountain 5 : 5
Height of mountain 6 : 0
Height of mountain 7 : 0
Yet, it is firing on mountain 7.
Effectively, the variables should be as follows for this loop:
mountain_heights = [0, 4, 0, 5, 0, 5, 0, 0]
max(mountain_heights) = 5
result_dictionary = {
0 : 0,
1 : 4,
2 : 0,
3 : 5,
4 : 0,
5 : 5,
6 : 0,
7 : 0
}
Thus the loop should return the first key
in result_dictionary
with 5
as the value
, which is 3.
This works in compilers I have tried, but is firing at mountain 7 in the exercise.
Any ideas?
I am having the same issue, only on this particular test case, and I have tried running it in compilers with complete success.
Your problem is that mountains 1 and 7 are the same height, so on the second turn, you are printing twice. All the output is cached up in STDOUT, and will eventually become a turn output. You can see this better by adding the following print statements:
# in the first for loop
print("INPUT {} {}: {}".format(turn_num, i, mountain_h), file=sys.stderr)
# in the if in the second for loop
print("OUTPUT {}: {}".format(turn_num, key), file=sys.stderr)
Then your output will look like the following:
Game information:
Let's destroy those mountains to secure our landing...
Height of mountain 0 : 0
Height of mountain 1 : 6
Height of mountain 2 : 0
Height of mountain 3 : 5
Height of mountain 4 : 0
Height of mountain 5 : 8
Height of mountain 6 : 0
Height of mountain 7 : 6
1 / 7
Standard Error Stream:
INPUT 1 0: 0
INPUT 1 1: 6
INPUT 1 2: 0
INPUT 1 3: 5
INPUT 1 4: 0
INPUT 1 5: 8
INPUT 1 6: 0
INPUT 1 7: 6
OUTPUT 1: 5
Standard Output Stream:
5
Game information:
Your spaceship targeted mountain 5, your altitude is now 9
Height of mountain 0 : 0
Height of mountain 1 : 6
Height of mountain 2 : 0
Height of mountain 3 : 5
Height of mountain 4 : 0
Height of mountain 5 : 5
Height of mountain 6 : 0
Height of mountain 7 : 6
2 / 7
Standard Error Stream:
INPUT 2 0: 0
INPUT 2 1: 6
INPUT 2 2: 0
INPUT 2 3: 5
INPUT 2 4: 0
INPUT 2 5: 5
INPUT 2 6: 0
INPUT 2 7: 6
OUTPUT 2: 1
OUTPUT 2: 7
Standard Output Stream:
1
Game information:
Your spaceship targeted mountain 1, your altitude is now 8
BOOOOMM!! Nice Shot!
Height of mountain 0 : 0
Height of mountain 1 : 4
Height of mountain 2 : 0
Height of mountain 3 : 5
Height of mountain 4 : 0
Height of mountain 5 : 5
Height of mountain 6 : 0
Height of mountain 7 : 6
3 / 7
Standard Error Stream:
INPUT 3 0: 0
INPUT 3 1: 4
INPUT 3 2: 0
INPUT 3 3: 5
INPUT 3 4: 0
INPUT 3 5: 5
INPUT 3 6: 0
INPUT 3 7: 6
OUTPUT 3: 7
Standard Output Stream:
7
Game information:
Your spaceship targeted mountain 7, your altitude is now 7
Height of mountain 0 : 0
Height of mountain 1 : 4
Height of mountain 2 : 0
Height of mountain 3 : 5
Height of mountain 4 : 0
Height of mountain 5 : 5
Height of mountain 6 : 0
Height of mountain 7 : 0
4 / 7
Standard Error Stream:
INPUT 4 0: 0
INPUT 4 1: 4
INPUT 4 2: 0
INPUT 4 3: 5
INPUT 4 4: 0
INPUT 4 5: 5
INPUT 4 6: 0
INPUT 4 7: 0
OUTPUT 4: 3
OUTPUT 4: 5
Standard Output Stream:
7
Game information:
Your spaceship targeted mountain 7, your altitude is now 6
Height of mountain 0 : 0
Height of mountain 1 : 4
Height of mountain 2 : 0
Height of mountain 3 : 5
Height of mountain 4 : 0
Height of mountain 5 : 5
Height of mountain 6 : 0
Height of mountain 7 : 0
5 / 7
Standard Error Stream:
INPUT 5 0: 0
INPUT 5 1: 4
INPUT 5 2: 0
INPUT 5 3: 5
INPUT 5 4: 0
INPUT 5 5: 5
INPUT 5 6: 0
INPUT 5 7: 0
OUTPUT 5: 3
OUTPUT 5: 5
Standard Output Stream:
3
Game information:
Your spaceship targeted mountain 3, your altitude is now 5
Height of mountain 0 : 0
Height of mountain 1 : 4
Height of mountain 2 : 0
Height of mountain 3 : 2
Height of mountain 4 : 0
Height of mountain 5 : 5
Height of mountain 6 : 0
Height of mountain 7 : 0
6 / 7
Standard Error Stream:
INPUT 6 0: 0
INPUT 6 1: 4
INPUT 6 2: 0
INPUT 6 3: 2
INPUT 6 4: 0
INPUT 6 5: 5
INPUT 6 6: 0
Standard Output Stream:
5
Game information:
You crashed your spaceship on mountain 5
Height of mountain 0 : 0
Height of mountain 1 : 4
Height of mountain 2 : 0
Height of mountain 3 : 2
Height of mountain 4 : 0
Height of mountain 5 : 5
Height of mountain 6 : 0
Height of mountain 7 : 0
Notice that on turn 2, you output BOTH 1 and 7, and then on turn 3, you output 7 again.
- danBhentschel
found it…oh well atleast now i know i dont like this games
Because?
- danBhentschel
i find the descriptions to what i have to do to solve the problem verry confusing
Fair enough. It’s not for everybody.
- danBhentschel
And to be even more fair… all descriptions weren’t created equal.
Excellent reply!! Thank you for the explanation. I never would have worked it out otherwise.