# Shadows of the Knight - Episode 1 - Puzzle discussion

#85

Could someone help me with it because i have no idea how to solve it unless i hard code it?I am writing the program in c++.

#86

Try to cut the grid in half with each guess. You can google ābinary searchā for some examples of how this is accomplished.

#87

first of all i cant understand what to do and how to doā¦ pls help how to start this puzzleā¦i am beginner

#88

guys i wanna run a virtual loop (doesn t make an output) in the end of it i shall have the Y and X of the bomb
.
BUT I DON T KNOW WHAT IS THE INPUT VALUE OF ābombDirā when batman get to it ???

#89

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

#90

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.

#91

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

#92

Made it. I got some practice.

#93

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

#94

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;
}``````

Shadows of the Knight - Episode 2 - Puzzle discussion
#95

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

#96

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.

#97

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

#98

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

#99

ļ¼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)

#100

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?

#101

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.

#102

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!!

#103

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)

#104

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.