Codingame : Power of Thor - Episode 1

Root(√)·2020년 8월 27일

https://www.codingame.com/training/easy/power-of-thor-episode-1

오늘 토르 라그나로크를 보고 나니 이 문제를 풀고 싶어져서 풀어봤다.

import sys
import 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.

# light_x: the X position of the light of power
# light_y: the Y position of the light of power
# initial_tx: Thor's starting X position
# initial_ty: Thor's starting Y position
light_x, light_y, initial_tx, initial_ty = [int(i) for i in input().split()]

# game loop
while True:
    remaining_turns = int(input())  # The remaining amount of turns Thor can move. Do not remove this line.

    # Write an action using print
    # To debug: print("Debug messages...", file=sys.stderr, flush=True)
    
    # N 
    if light_y < initial_ty and light_x == initial_tx :
        initial_ty -= 1
        print("N")

    # NE
    elif light_x > initial_tx and light_y < initial_ty:
        initial_tx += 1
        initial_ty -= 1
        print("NE")
    # E
    elif light_x > initial_tx and light_y == initial_ty:
        initial_tx += 1
        print("E")

    # SE
    elif light_x > initial_tx and light_y > initial_ty:
        initial_tx += 1
        initial_ty += 1
        print("SE")
    # S
    elif light_y > initial_ty and light_x == initial_tx :
        initial_ty += 1
        print("S")
    # SW
    elif light_x < initial_tx and light_y > initial_ty:
        initial_tx -= 1
        initial_ty += 1
        print("SW")
    # W 
    elif light_x < initial_tx and light_y == initial_ty:
        initial_tx -= 1
        print("W")
    # NW
    else:
        initial_tx -= 1
        initial_ty -= 1
        print("NW")
    # A single line providing the move to be made: N NE E SE S SW W or NW
    
profile
Software Engineer

0개의 댓글