Shadows of the Knight - Episode 1 - Puzzle discussion


#147

I succed to do one action every turn but my character did this again. He moves in RD then in D and he started again!!! :confused:


#148

i need help with the shadows of the knight


#149

i cant get past tower because there is invalid input. how do i fix this? is there a way to do this without using the bisection method? (my coding language is python)


#150

i cant get past tower because there is invalid input. how do i fix this? is there a way to do this without using the bisection method? (my coding language is python)
[/quote]


#151

help!! what is wrong with my code? All of test cases are pass,but the submit result is 85%,not 100%.

import sys
import math

w, h = [int(i) for i in input().split()]
n = int(input())  # maximum number of turns before game over.
x0, y0 = [int(i) for i in input().split()]


xw = w - x0
yh = h - y0

x1 = x0
y1 = y0

s = []

while True:
    bomb_dir = input()  # the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)

   
s.append(bomb_dir)

if len(s)==1:            
    
    if s[0]=='U':
        y = y1
    if s[0]=='D':
        y = yh
    if s[0]=='L':
        x = x1
    if s[0]=='R':
        x = xw
    if s[0]=='UR':
        y = y1
        x = xw
    if s[0]=='UL':
        y = y1
        x = x1
    if s[0]=='DR':
        y = yh
        x = xw
    if s[0]=='DL':
        y = yh
        x = x1
      
     
if bomb_dir == 'U':      
    if y>=2:    
        y = (y//2)
    else:
        y=1
    y0 = y0-y
         
elif bomb_dir == 'UR':
    if x>=2 and y>=2:
        x = (x//2)
        y = (y//2)      
    elif x>=2 and y<2:
        x = (x//2)
        y = 1
    elif x<2 and y>=2:
        x = 1
        y = (y//2)
    elif x<2 and y<2:
        x = 1
        y = 1
    
    x0 = (x0+x)
    y0 = (y0-y)
    
elif bomb_dir == 'R':               
    if x>=2:
        x = (x//2)
    else:
        x = 1
    
    x0 = (x0+x)
    
    
elif bomb_dir == 'DR':
    if x>=2 and y>=2:
        x = (x//2)
        y = (y//2)      
    elif x>=2 and y<2:
        x = (x//2)
        y = 1
    elif x<2 and y>=2:
        x = 1
        y = (y//2)
    elif x<2 and y<2:
        x = 1
        y = 1
        
    x0 = (x0+x)
    y0 = (y0+y)

elif bomb_dir == 'D':  
    if y>=2:
        y = (y//2)
    else:
        y = 1
    
    y0 = y0+y
    
elif bomb_dir == 'DL':
    if x>=2 and y>=2:
        x = (x//2)
        y = (y//2)      
    elif x>=2 and y<2:
        x = (x//2)
        y = 1
    elif x<2 and y>=2:
        x = 1
        y = (y//2)
    elif x<2 and y<2:
        x = 1
        y = 1

    x0 = x0-x
    y0 = y0+y
    
elif bomb_dir == 'L':
    
    if x>=2:
        x = (x//2)
    else:
        x = 1
    x0 = (x0-x)
    
    
elif bomb_dir == 'UL':
    
    if x>=2 and y>=2:
        x = (x//2)+1
        y = (y//2)+1     
    elif x>=2 and y<2:
        x = (x//2)+1
        y = 1
    elif x<2 and y>=2:
        x = 1
        y = (y//2)
    elif x<2 and y<2:
        x = 1
        y = 1

    x0 = (x0-x)
    y0 = (y0-y)

       
print(x0, y0)

#152

can you explain what you tried to implement? It’s fairly difficult to read that kind of program with repetitive chunks and unnamed variables.


#153

Hello, can anynoe help me understand why we dont go to the bomb at the first time. And what does h means with infinitve loop?

i havent complete any task like this again can anyne help me please


#154

i am stuck at ‘Evasive’ stage at round 6 ($N=0~6).
The red circle(or target) at this mode would be varient, but i don’t get the answer at round 6.


#155

why I see this error:
Failure: invalid input. Expected ‘Integer’ but found ‘x’


#156

Standard Output Stream:
x y
Game information:
Failure: invalid input. Expected ‘Integer’ but found ‘x’

You printed it as a String instead of printing the values of your variables.