Shadows of the Knight - Episode 1 - Puzzle discussion

Hello everyone, could someone help me understand how to apply the binary search even though I know the directions and not the target value?

Too much of guessing. No mention how W, H, N, X0, Y0 are generated? Seems randomly by you, I started to put conditions into values. Where is bomb location, shall I create a variable or your engine creates it? I don’t get it at, please advise.

im having trouble on tower could you help me see what im doing wrong

Made it. I got some practice.

I have not fully understand why it will help but thank you

here is my c++ code ,but it just pass a few test, most of the failed tests is about the late time , i think the range should be revised , but i dont nknow how to develop this code

 #include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

/**
 * Auto-generated code below aims at helping you parse
 * the standard input according to the problem statement.
 **/
int main()
{
    int W; // width of the building.
    int H; // height of the building.
    cin >> W >> H; cin.ignore();
    int N; // maximum number of turns before game over.
    cin >> N; cin.ignore();
    int X0;
    int Y0;
    int first_x =0 ;
    int first_y = 0;
    int last_x = W;
    int last_y = H;
    //the batman start location.
    cin >> X0 >> Y0; cin.ignore();

    // game loop
    while (1) {
        string bombDir; // the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)       
        cin >> bombDir; cin.ignore();

        // Write an action using cout. DON'T FORGET THE "<< endl"
        if(bombDir[0] == 'U')
        {
            last_y --;
        }
        else if(bombDir[0] == 'D')
        {
            first_y ++;
        }
        if(bombDir[1] =='L')
        {
            last_x--;

        }
        else if(bombDir[1] == 'R')
        {
           first_x ++;
        }
    X0 = first_x + (last_x-first_x)/2;
    Y0 = first_y + (last_y - first_y)/2;
    cout <<X0<<" "<<Y0<< endl;   
    }
   

    return 0;
}

can you help me ,some test i got the bomb explode

I don’t get what I’m supposed to be doing for this episode. I type the coordinates into print, but my progress isn’t getting recorded, and the test cases keep saying ‘check again’, even when I’ve typed in the right coordinates.
I’m using JavaScript.

You type the coordinates: what coordinates ?
What are the right coordinates in your mind ?
Do you take into account the inputs ?

You are qualified to be batman if you’re a rich orphan and have a strange fear of bats.

(2,5) UR grow to (5,4)
i think it is wrong,who can tell me
(2,5) UR later, and i think it is to be:
(2,5)+(9,0) / 2 = (5,2)

Hi,
I don’t understand AT ALL what should be done. Even the example:
5 4 *Batman jumps to window (5,4)
Why???
Why the next jump should be (5,4)? What is the logic?

Hi,
In the example, you start on a cell located row 5 column 2.
You have to go to the cell where the bombs are, but you don’t know which one.
You just know the direction: upward-right.
So you try a new location, which must be upper and righter.

If you were basic human, you would try to jump on the next adjacent cell, the one on row 4 column 3.
But you are the Batman! You can jump everywhere you want.
So you try the cell on row 4 (nice, it’s upper than starting row 5) and column 5 (nice too, it’s on the right to the starting column 2).
But you could have chose a cell on row 0 and column 8, or any other cell: it’s up to you.

Once on your new location, you receive new instructions, and have to guess a new jump, and so on until you find the final location.
Good luck Batman.

cg123 have totally right! You can take support over here : https://en.wikipedia.org/wiki/Binary_search_algorithm . Apply the same logic and it works great!!

Hi everyone
can someone help me.
I got this error
Failure: invalid input. Expected ‘x y’ but found ‘4 8 40’
but I have no idea why ! I didnt change the line about input. I dont know why there is 3 …
(sorry im a beginner)

When it’s complaining about invalid input, it’s saying that the inputs it received from you are bad, meaning that it’s actually your OUTput that is the problem.

Specifically, it was expecting 2 numbers for x and y, but you gave it 3 numbers.

1 Like

ok thanks Mr Anderson

Nice,love it

Bonjour; je ne comprends pas quelle forme doit avoir la sortie.

  1. System.out.println(X Y);
  2. System.out.println(X, Y);
  3. System.out.println(“X, Y”);

Pourriez-vous m’aider svp ?

always as a String. So if you need to output a position, you do

System.out.println(x+" "+y);