jinux127 2022. 2. 15. 21:52

function solution7(N,plans){
	  let move_types = ['L', 'R', 'U', 'D'];
    let dx = [0, 0, -1, 1];
    let dy = [-1, 1, 0, 0];
		// LRUD에 맞게 이동 좌표 설정

    let plan = plans.split(' ');
    let x = 1, y = 1;
    for (const iterator of plan) {
        let nx = 0;
        let ny = 0;
        for (let index = 0; index < 4; index++) {
            if (iterator == move_types[index]) {
                nx = x + dx[index];
                ny = y + dy[index];
            }
        }
        if (nx< 1 || ny< 1 || nx > N || ny > N) continue;

        x = nx;
        y = ny;

    }
    console.log(`${x} ${y}`);
}