치춘짱베리굿나이스

[백준] 6840 본문

Who is in the middle?

문제

In the story Goldilocks and the Three Bears, each bear had a bowl of porridge to eat while sitting at his/her favourite chair. What the story didn’t tell us is that Goldilocks moved the bowls around on the table, so the bowls were not at the right seats anymore. The bowls can be sorted by weight with the lightest bowl being the Baby Bear’s bowl, the medium bowl being the Mama Bear’s bowl and the heaviest bowl being the Papa Bear’s bowl. Write a program that reads in three weights and prints out the weight of Mama Bear’s bowl. You may assume all weights are positive integers less than 100.

풀이

const middle = () => {
  const arr = require("fs")
    .readFileSync("/dev/stdin")
    .toString()
    .trim()
    .split("\n")
    .map(Number)
    .sort((a, b) => a - b);
  console.log(arr[1]);
};

middle();

'Javascript + Typescript > 자바스크립트로 알고리즘풀기' 카테고리의 다른 글

[백준] 27323  (0) 2023.07.17
[백준] 7891  (0) 2023.07.17
[백준] 4470  (0) 2023.07.14
[백준] 2393  (0) 2023.07.05
[백준] 2083  (0) 2023.06.30
Comments