๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ“ ์•Œ๊ณ ๋ฆฌ์ฆ˜/Softeer

[Javascript(NodeJS)/Softeer] Lv1. ๊ทผ๋ฌด ์‹œ๊ฐ„

728x90

https://softeer.ai/practice/6254

 

Softeer - ํ˜„๋Œ€์ž๋™์ฐจ๊ทธ๋ฃน SW์ธ์žฌํ™•๋ณดํ”Œ๋žซํผ

 

softeer.ai

 

ํ˜„๋Œ€ ์†Œํ”„ํ‹ฐ์–ด 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