Thank you so much for this challenge. I spent a whole day on it to figure it out from scratch and without any help or cheating. It was a great experience, I learned a lot from it.
Iām pretty new to coding, so this one was pretty difficult for me, until I started putting comments on my code to keep track of what it was actually doing, until I started putting comments on my code to keep track of what I was actually doing. Turned out I was trying to send moves without adding them to my position. Whoops. Finally got everything to work except the evasive test, learned how to force all my moves to round up, and got that sweet, sweet 100%
Hi, Iām trying to solve this puzzle using Python 3.
Is it normal that when Batman is on the same ligne as the bomb, my code returns True when checking if āDā and āRā are in the variable bomb_dir ? Shouldnāt bomb_dir only contain āRā ?
I cannot upload images, so hereās my code:
while True:
bomb_dir = input()
x = 0
y = 7
print(x, y)
print(x, y)
if āDā in bomb_dir and āRā in bomb_dir:
print(True)
And hereās the error message I got:
Failure: invalid input. Expected āx yā but found āTrueā
Batman moved from window (0,7) to window (0,7)
The bombs are located to the right of Batman
Thank you in advance for your time and answers
yes, itās normal. You can see DR
(down-right) is in the list of possible directions
gotta say that was hard to me, but the solution is justā¦ nahā¦
I need help i do not know what iām doing
for javascript
Yeah, indeed Javaās crypt is a hard level in this game.
Is there really a generic solution, that solves the test case 4 Tower in a generic way for all possible bomb positions? There are 79 possible positions and 79 > 2^6 so there will always be cases where one needs 7 hops or am I getting something wrong?
thanks in advance and best regards
Of course thereās a solution !
My code solve this test and the corresponding validator in 5 jumps.
I donāt get your ā79 > 2^6āā¦
I can also code a solution that works for that test case and maybe also for the other test cases, but generally speaking Tower comes down to finding a random number from 1 to 79 by only asking yes/no questions, in this case āis the bomb (below | above) meā. That comes don to finding a binary representation of the sought number. With 6 bits you can only represent 64 (2^6) numbers, so I doubt that there is a generic solution that solves every possible test case. But maybe I am missing something.
I meant āOf course thereās a generic solution !ā and āMy generic code solve this test and the corresponding validator in 5 jumps.ā
Finding generic solutions and donāt hardcode the tests is one of principles of the platform.
I think that your binary representation approach is misleading you. Have you toke a look to the resources on the puzzle page ?
Hello. Sorry Iām new here. Is there a way to know the location of the bomb or how itās represented in the problem (like does it have a value)? Thanks.
The bomb is represented by two coordinates (x, y) but these coordinates are hidden, theyāre never given to you.
The only information you have are these U, R, D, L indications.
The only moment you know the coordinates of the bomb is when you finally output them and the game referee tells you that you find the bomb.
As for what strategy you should use to find the bomb fast enough, just think about it like a 2D version of the āguess the numberā game where you must guess a number and youāre told if itās bigger or smaller.
Say you must guess a number between 1 and 100, a good strategy would be to try 50 first, so that you can halve your space search. And then at every turn you try to halve your space search like this.
Hello, is there is something faster than binary search for this problem ? it seem i miss one extra turn to fully complete the tower test
Binary search is the way. Try doing this by hand and see if your algorithm gets the same results
yea i am not understaning how they want me to code this.
Hi,
I used the binary search. It passed the first test case but not sure why it didnāt pass the other test cases. Please help.
while True:
bomb_dir = input() # the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)
if bomb_dir == 'U':
y0 = (h+(y0-1))//2
x0 = (x0 + w) // 2
elif bomb_dir == 'UR':
y0 = (h+(y0-1))//2
x0 = (w+(x0+1))//2
elif bomb_dir == 'R':
x0 = (w+(x0+1))//2
y0 = (h+y0)//2
elif bomb_dir == 'DR':
y0 = (h+(y0+1))//2
x0 = (w+(x0+1))//2
elif bomb_dir == 'D':
y0 = (h+(y0+1))//2
x0 = (x0 + w) // 2
elif bomb_dir == 'DL':
y0 = (h+(y0+1))//2
x0 = (w+(x0-1))/2
elif bomb_dir == 'L':
x0 = (w+(x0-1))//2
y0 = (h+y0)//2
elif bomb_dir == 'UL':
y0 = (h+(y0-1))//2
x0 = (w+(x0-1))//2
print("{0} {1}".format(x0, y0))
Hi,
I need a little help!
All my tests are passing in the IDE but āLess Jumpsā wonāt pass on submitā¦
Whatās the problem?
Thankās in advance!