Shadows of the Knight - Episode 1 - Puzzle discussion

@TwoSteps Ok, as soon as i get home I’ll post a video of the issue. Thanks for your support

@TwoSteps

I can’t take a video of the problem but I can paste a screen of it: https://pasteboard.co/0eCL3mF7TMDL.png

As you can see the output window is black even if I had run the first test

I can’t reproduce the issue. Can you reproduce this on other tests and with other puzzles?
I believe you’ve some extension messing up with the display.

Can you share a replay of the play you run so we can double-check?

Hi! My C# code analyses each turn where is situed the bomb (U, D, R, L, UR, UL, DR, DL) with this line: string bombDir = Console.ReadLine();
then x and y (the new values of Batman’s position) increase, decrease or stay equal:

 else if (bombDir == "UR")
        { x++;
y--;
 Console.WriteLine(x + " " + y) ;}

And it works for the 1, 2 and 3 test. But I don’t know how to calculate the size of the jump Batman must do to arrive before the end of the rounds.
Any idea? thx

All of you are talking about dissection so I think I don’t use the good method…since the beginning

Ok, binary search works better than sequential…all successful tests but the last…

Ok all test done now with respectually 3 - 6 - 6 - 6 - 5 - 7 and 14 rounds for each one.
I’m sure mine could be a shorter code, but I don’t know how to process at the moment.
It results difficult to resolve the case where Batman arrives just one step before the bomb, so I bypass it with something I sure a better solution exists.
I’m so curious to see the expert’s code.
I’m a big beginner, I approached the coding with Basic Language on C64 computer…yes I’m an old big beginner…

Keep it up! You’ll be able to see others’ solutions in the same language you use after your code passes all the validators.

2 Likes

please help i dont really understand what i have to do with U,UR… should i creatte a list with that position or something else?

in bomb_dir = input() can i modify this or leave?

Please refer to the “Input” and “Output” explanation in the puzzle statement. “U”, “UR”, etc indicate the direction of where the bomb is. You then have to decide where you want to jump to by outputting the desired coordinates.

bomb_dir = input() is needed so that your code can read the bomb direction as mentioned above. You can do anything else you want below that line of code.

Fun exercise! Thanks

Hello world!

I solved this game case 1,2,3,4,5,7
ecept case 6!!!

Could you tell me why?

here is my code

Thanks!

import sys
import math

Auto-generated code below aims at helping you parse

the standard input according to the problem statement.

w: width of the building.

h: height of the building.

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()]

uh = 0
dh = h
lw = 0
rw = w

game loop

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

# Write an action using print
# To debug: print("Debug messages...", file=sys.stderr, flush=True)
# the location of the next window Batman should jump to.

if bomb_dir == "U":
    if y0 == 1:
        y0 = 0
    else:
        dh = y0
        y0 = y0 - ((y0-uh)//2)
    print(x0,y0)

elif bomb_dir == "UR":
    if y0 == 1:
        y0 = 0
    else:
       lw = x0
       x0 = x0 + ((rw-x0)//2)
       dh = y0
       y0 = y0 - ((y0-uh)//2)
    print(x0,y0)

elif bomb_dir == "R":
    lw = x0
    x0 = x0 + ((rw-x0)//2)
    print(x0,y0)

elif bomb_dir == "DR":
    lw = x0
    x0 = x0 + ((rw-x0)//2)
    uh = y0
    y0 = y0 + ((dh-y0)//2) 
    print(x0,y0)

elif bomb_dir == "D":
    uh = y0
    y0 = y0 + ((dh-y0)//2) 
    print(x0,y0)

elif bomb_dir == "DL":
    if x0 == 1:
        x0 = 0
    else:
        rw = x0
        x0 = x0 - ((x0-lw)//2)
        uh = y0
        y0 = y0 + ((dh-y0)//2) 
    print(x0,y0)

elif bomb_dir == "L":
    if x0 == 1:
        x0 = 0
    else:
        rw = x0
        x0 = x0 - ((x0-lw)//2)
    print(x0,y0)

elif bomb_dir == "UL":
    if y0 == 1:
        y0 = 0
        rw = x0
        x0 = x0 - ((x0-lw)//2)
    elif x0 == 1:
        x0 = 0
        dh = y0
        y0 = y0 - ((y0-uh)//2)
    else:
        rw = x0
        x0 = x0 - ((x0-lw)//2)
        dh = y0
        y0 = y0 - ((y0-uh)//2)
    print(x0,y0)

Please note that test cases and validators are different. Your code has to be general enough to pass the validators too.
If you click “Results”, then “Details”, you’ll find which validator you’re failing, and see a replay of it. Then you can try to debug by yourself.

1 Like

Thanks your reply!

can someone like help me im new to coding please help! TvT

You should begin with an easier puzzle, Onboarding for example.

Hello,
my program is successfully tested but still the test “correct cutting” is not validated. I am really tired to finish this program, any help please?

it is ok, all are done,

Worst puzzle ever

Took me 3 hours to figure out rounding error which caused it to require one turn to much (last case)
This here works in C# (int)Math.Floor((fX/2)+0.5f);

Please change and at least give a tolerance by one as this puzzle is about understanding Binary Tree and not examining rounding stuff

“Worst car ever. Took me 3 hours to figure out that wearing shoes was the cause of my difficulties to use the wheel with my feet.”
Joke apart, there’s no need to use any floating point numbers, the statement doesn’t suggest you should use any, the inputs are integers, and so are the waited outputs…
Nothing to change in the puzzle so, since seems to have complicated the things by yourself…

1 Like

sry I have a too overcomplicated way of thinking. no idea how to fix that
my IQ is just 115.

Struggle generally with grasping algorithms, that’s why I try to learn and this one was insanely frustrating to me