개발자 톡
연습문제 톡
진정한 효도
반례좀 알려주세용
- 등록일
- 2024-01-31 21:25:39
- 조회수
- 440
- 작성자
- ujm011
const input = require('fs').readFileSync(0).toString().trim().split('\n') const arrRow = input.map(item=> item.split(' ').map(Number)) let arrCol = [[],[],[]] for (let i = 0; i < arrRow.length; i++) { arrCol[0].push(arrRow[i][0]) arrCol[1].push(arrRow[i][1]) arrCol[2].push(arrRow[i][2]) } function add(arr){ let countArr = [] for (let i = 0; i < 3; i++) { let count1 = 0; let count2 = 0; let count3 = 0; for (let j = 0; j < 3; j++) { count1 = count1 + Math.abs(1 - arrRow[i][j]) count2 = count2 + Math.abs(2 - arrRow[i][j]) count3 = count3 + Math.abs(3 - arrRow[i][j]) } countArr.push(count1) countArr.push(count2) countArr.push(count3) } return countArr; } const result = [...add(arrRow),...add(arrCol)] console.log(Math.min(...result))
6,7 에서 실패하네용 ㅠㅠ
#진정한_효도