Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- typedef enum
- {
- false,
- true
- }bool;
- /**
- * 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.
- **/
- int main()
- {
- int lightX; // the X position of the light of power
- int lightY; // the Y position of the light of power
- int initialTX; // Thor's starting X position
- int initialTY; // Thor's starting Y position
- scanf("%d%d%d%d", &lightX, &lightY, &initialTX, &initialTY);
- bool right, left, up, down;
- // game loop
- while (1) {
- int remainingTurns;
- scanf("%d", &remainingTurns);
- right = lightX > initialTX;
- left = lightX < initialTX;
- up = lightY < initialTY;
- down = lightY > initialTY;
- if(right && up)
- {
- printf("NE\n");
- initialTX++;
- initialTY--;
- }
- else if(right && down)
- {
- printf("SE\n");
- initialTX++;
- initialTY++;
- }
- else if(right)
- {
- printf("E\n");
- initialTX++;
- }
- else if(left && down)
- {
- printf("SW\n");
- initialTX--;
- initialTY++;
- }
- else if(left && up)
- {
- printf("NW\n");
- initialTX--;
- initialTY--;
- }
- else if(left)
- {
- printf("W\n");
- initialTX--;
- }
- else if(up)
- {
- printf("N\n");
- initialTY--;
- }
- else
- {
- printf("S\n");
- initialTY++;
- }
- // printf("SE\n"); // A single line providing the move to be made: N NE E SE S SW W or NW
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement