[Softeer, JS] (21년 재직자 대회 예선) 비밀 메뉴

mxxn·2023년 7월 28일

Softeer

목록 보기
7/8

문제

문제 링크 : 비밀 메뉴

풀이

const readline = require('readline');

const rl = readline.createInterface({
    input : process.stdin,
    output : process.stdout
});
const inputArr = []
rl.on('line', input => {
    inputArr.push(input.split(' ').map(el => +el))
})

rl.on('close', () => {
    const firstLine = inputArr[0]
    if(firstLine[0] > firstLine[1]){
        console.log('normal')
        process.exit();
    }
    let secondLine = inputArr[1].join('')
    let thirdLine = inputArr[2].join('')
    thirdLine.includes(secondLine) ? console.log('secret') : console.log('normal')
})
  1. line별로 나누어 inputArr에 push
  2. firstLine의 0번째와 1번째를 비교하여 0번째가 더 크면 normal 출력
    • 애초에 조작 수가 달라서 secret이 나올 수 없음
  3. secondLine와 thirdLine은 문자열로 만들어 includes로 secret/normal 출력 결정
profile
내일도 글쓰기

0개의 댓글