개발자 톡

연습문제 톡 진정한 효도

4, 7, 8, 10, 11 에서 오류가 나는 이유가 뭘까요..?

등록일
2024-02-05 20:12:59
조회수
256
작성자
snowdogs

const readline = require("readline")


const rl = readline.createInterface({

  input: process.stdin,

  output: process.stdout

})


let input = []


rl.on("line", (line) => {


  input.push(line)

}).on("close", ()=> {

  const graph = []

  for(let i=0; i<3; i++) {

    graph.push(input[i].split(" ").map(Number))

  }


  let group = []


  // 가로

  for(let i=0; i<3; i++) {

    group.push(graph[i])

  }


  // 세로

  for(let i=0; i<3; i++) {

    group.push([graph[0][i],graph[1][i],graph[2][i]])

  }


  let answer = 1e9


  for(let g of group) {

    let result = new Set()

    g.forEach(v => result.add(v))


    answer = Math.min(Math.max(...result) - Math.min(...result), answer)

  }


  console.log(answer)

   

   

  process.exit();

})


#진정한_효도

이 카테고리의 톡 더보기