Skip to content

Commit 4698dc2

Browse files
[BOJ] 1085 직사각형에서 탈출 (B3)
1 parent 08eb43a commit 4698dc2

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

서정우/9주차/260225.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const fs = require("fs");
2+
const filePath =
3+
process.platform === "linux" ? "/dev/stdin" : "./서정우/input.txt";
4+
const input = fs
5+
.readFileSync(filePath)
6+
.toString()
7+
.trim()
8+
.split("\n")
9+
.map((el) => el.trim());
10+
11+
const [x, y, w, h] = input[0].split(" ").map(Number);
12+
13+
const horizontalDistance = Math.min(x, w - x);
14+
const verticalDistance = Math.min(y, h - y);
15+
16+
console.log(Math.min(horizontalDistance, verticalDistance));

서정우/input.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
5
2-
1 1 2 2 3 3 4 4 5 5
1+
161 181 762 375

0 commit comments

Comments
 (0)