Ah yes…
So much detail to check out…
Thank you for you quick answer. You’re great.
- Part of the Two Conditions python solution
def get_value(c1, c2, value1, value2):
if value1[0] < value2[0]:
value1[0]+=1
return c1
elif value1[0] > value2[0]:
value1[0]-=1
return c2
return ''
I am kinda confused. I was able, to create a code, that solves theoraticly all puzzles. But because of the shape of the boundary, it doesn`t work. Are you supossed to create a different solution, for every puzzle or is there a solution for all puzzles? if it helps, here is my code:
import java.util.*;
import java.io.*;
import java.math.*;
/**
* 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
String directionX = "";
String directionY = "";
double distanceX = 0;
double distanceY = 0;
double endDistance = 0;
// game loop
while (true) {
int remainingTurns = in.nextInt(); // The remaining amount of turns Thor can move. Do not remove this line.
// Write an action using System.out.println()
// To debug: System.err.println("Debug messages...");
directionX = "";
directionY = "";
if (lightX < initialTx){
initialTx --; directionX = "W";
}
if (lightX > initialTx){
initialTx --; directionX = "E";
}
if (lightY < initialTy){
initialTy --; directionY = "N";
}
if (lightY > initialTy){
initialTy --; directionY = "S";
}
System.err.println("initial X: " + initialTy);
System.err.println("initial y: " + initialTx);
System.err.println("direction X: " + directionY);
System.err.println("direction Y: " + directionX);
System.err.println("direction Y: " + directionX + directionY);
System.out.println(directionY + directionX);
}
}
}
thx for any help
Two of the --
s should be ++
s instead.
Oh, thanks for the help. but it should be ++E insted of --E, right?
I’m not talking about directions there The “s” in “
--
s” just indicates the plural form.
I don’t know. I initially defined two functions and i went over it a hundred times, it would only run the straight lines. so i dumped the functions and had it do the same thing, just loop through the full thing instead of print(funcA(y,yy)+funcB(x,xx)) and it wwas still broken. I know the grid gives North a negative value. Actually funny enough the first time i tried this I did not read that part and I was doing arc tangents to get headings lol. anyways, i had to workaround by making him just drop whatever he was doing and start walking west until the sun goes down if he hits one particular coordinate that seemed to be breaking it. I tried doing a +1 on the comparison in general, just for that value… the only thing, literally the only thing that worked was to just force him out if he hit that coordinate
ok so i nearly pulled my hair out, what little i have, doing this but there is a key concept that fixed my issues. i was unaware that the y axis, north and south, does not move the way you learned in math class. as a point moves up the y axis is actually moving down so i had to update as such and boom 3 hours and some reading later it works for all test cases. if(ty>ly){fly=‘N’;ty --;} else if (ty<ly) {fly=‘S’;ty ++;} in case this helps any one because i almost lost all of my cool. it still barley makes sense to me but im thinking of it as the world moving instead of you.