Exercise 3: Reach the highest summit (advanced) error
Hello AI admins!
When I did the Exercise 3: Reach the highest summit (advanced) i finally put in a code that I though was correct (which actually was identical to the solution below suprisingly), The Exercise passed and got approved with the checkmark after a while, but still this error appears, maybe something is wrong with the test array? Or have I done something wrong?:
The answer is not correct - Test cases: 0 / 1
File "/usr/local/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
yield
File "/usr/local/lib/python3.8/unittest/case.py", line 676, in run
self._callTestMethod(testMethod)
File "/usr/local/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
method()
File "/app/test/test_main.py", line 23, in test_answer
self.assertGreaterEqual(h[x], h[x + n])
File "/usr/local/lib/python3.8/unittest/case.py", line 1316, in assertGreaterEqual
self.fail(self._formatMessage(msg, standardMsg))
File "/usr/local/lib/python3.8/unittest/case.py", line 753, in fail
raise self.failureException(msg)
Error: 1.4323182036435407 not greater than or equal to 1.4446891332850393Example solution
def climb(x):
# keep climbing until we've found a summit
summit = False
# edit here
while not summit:
summit = True
for x_new in range(max(0, x-5), min(99, x+5)):
if h[x_new] > h[x]:
x = x_new # here is higher, go here
summit = False # and keep going
return xBest regards
Johan Westerberg