Hi, just trying ‘Easy Angle’ with Python3 and having no luck. I’m a complete beginner and don’t understand how to incorporate the boundary into my code.
I get this error:
Standard Output Stream:
SW
Game information:
Failure: Thor wandered off the path and died (invalid position). Thor position = (17,18). Light position = (0,17). Energy = 31
Hi! When I tried to submit my solution my third task have failed, and I don’t know why because all TC have passed.
That is message that was shown on submit - The validators differ from the puzzle test cases to prevent hard coded solutions. This is why you can have some fails here even if all of the tests provided in the IDE have been successfully passed.
I don’t know what does that mean, my code isn’t hardcoded for this test case.
Would be grateful for any help or ideas
Auto-generated code below aims at helping you parse
the standard input according to the problem statement.
Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders.
**/
class Player {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int lightX = in.nextInt(); // the X position of the light of power
int lightY = in.nextInt(); // the Y position of the light of power
int initialTx = in.nextInt(); // Thor's starting X position
int initialTy = in.nextInt(); // Thor's starting Y position
Integer positionX = Integer.valueOf(initialTx);
Integer positionY = Integer.valueOf(initialTy);
while (true) {
int remainingTurns = in.nextInt();
StringBuilder direction = new StringBuilder();
int horizontalDirection = initialTx - lightX;
int verticalDirection = initialTy - lightY;
if (verticalDirection > 0 && positionY != 0) {
direction.append("N");
positionY--;
} else if (verticalDirection < 0 && positionY != 17) {
direction.append("S");
positionY++;
}
if (horizontalDirection > 0 && positionY != 0) {
direction.append("W");
positionX--;
} else if (horizontalDirection < 0 && positionX != 39) {
direction.append("E");
positionX++;
}
System.out.println(direction.toString());
}
}
The validators differ from the puzzle test cases. This is why you can have some fails here even if all of the tests provided in the IDE have been successfully passed.
hi guys, i have solved test case #1, #2, #3 but couldn’t get #4… i am not sure what to do to improve it, my code just compares ratio of width and height and chooses which one is closest.
If they are equal then neither the if or elif are true so ‘ns’ or ‘ew’ will remain ‘’. When they are concatenated at the print statement if they are both blank then Thor is already at the power.