728x90
https://softeer.ai/practice/6254
ํ๋ ์ํํฐ์ด Lv1. ๊ทผ๋ฌด ์๊ฐ js ํ์ด
๊ฐ์๊ธฐ ์ฝํ ์์ ์ธ์ด๊ฐ ์๋ฐ์คํฌ๋ฆฝํธ๋ผ๋ ๊ฑธ ์๊ฒ๋ ๋
๊ธํ๊ฒ ์ฐ์ต๋ฌธ์ ๋ฅผ ํ์ด๋ณด๋๋ฐ.....
๊ทธ๋ฅ ๋์ ํ๋๊ฑฐ์ง๋ญ~~~
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let sum = 0;
min = 0;
hour = 0;
rl.on('line',input =>{
time = input.split(' ');
timesp = time.map(t=>t.split(':'));
min1 = Number(timesp[0][1]);
min2 = Number(timesp[1][1]);
h1 = Number(timesp[0][0]);
h2 = Number(timesp[1][0]);
if(min1<=min2){
min = min2 - min1;
hour = h2-h1;
} else {
min = (60-min1+min2);
hour = h2 - h1 - 1;
}
hour *= 60;
sum+= (hour+min);
})
rl.on('close', () =>{
console.log(sum);
})
readline์ ๊ณต์๋ฌธ์์์ ์น์ ํ๊ฒ ์๋ ค์ค์ ๋คํ์ด๋ค..^^
728x90
'๐ ์๊ณ ๋ฆฌ์ฆ > Softeer' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Javascript(NodeJS)/Softeer] Lv1. A+B (0) | 2024.06.27 |
---|---|
[C++/Softeer] Lv3. ์์๋๋ก ๋ฐฉ๋ฌธํ๊ธฐ (HSAT 7ํ ์ ๊ธฐ ์ฝ๋ฉ ์ธ์ฆํ๊ฐ ๊ธฐ์ถ) (0) | 2024.06.27 |
[C++/Softeer] Lv2. ํ์์ค ์์ฝ (0) | 2024.06.27 |
[C++/Softeer] Lv1. ์ํํ ํจ๋ (0) | 2024.06.26 |
[C++/Softeer] Lv3. ํจ๊ปํ๋ ํจ๋ (0) | 2024.06.26 |