๐งธ ์ ๋ ฅ๊ฐ์ ์ผ์ฐจ์ ๋ฐฐ์ด๋ก ๋ง๋ค์ด์ ํ์๋ค
const fs = require('fs');
const input = fs.readFileSync('/dev/stdin').toString().split(/\n| /);
const max = Math.max(...input);
let row=0;
while(row < 81){
for(let i = row; i < row+9; i++){
if(input[i]===String(max)){
console.log(max);
console.log((row/9+1)+ ' '+(i-row+1));
}
}
row+=9;
}
๐งธ ์ด์ฐจ์ ๋ฐฐ์ด์ ์ด๋ ค์..? ๋ค์ ํ์ด๋ดค๋ค.
๐ ์ ๋ ฅ๊ฐ์ด ๋ชจ๋ 0์ผ ๊ฒฝ์ฐ๋ฅผ ์๊ฐํด row, col๋ฅผ 1๋ก ์ด๊ธฐํํด์ฃผ๊ฑฐ๋ max,temp ๋น๊ตํ ๋ ๋ฑํธ๋ฅผ ๊ผญ ๋ถ์ฌ์ผํ๋ค!
const fs = require('fs');
const input = fs.readFileSync('/dev/stdin').toString().split('\n');
let max=0;
let row;
let col;
for(let i = 0; i < 9; i++){
//ํ ํ ๊ตฌํ๊ธฐ
const data=input[i].split(' ').map((el)=>parseInt(el));
//ํ ํ์์์ ์ต๋๊ฐ
const temp = Math.max(...data);
if(max<=temp){
max = temp;
row = i+1;
col = data.indexOf(max)+1;
}
}
console.log(max);
console.log(row+' '+col);