개인정보 수집 유효기간

https://school.programmers.co.kr/learn/courses/30/lessons/150370

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

function solution(today, terms, privacies) {
    // today: 오늘 날짜
    // terms: 약관 정보
    // privacies: 수집된 정보
    let answer = [];
    let expiration = [];
    const privacy = [];
    const term = [];
    today = new Date(today);
    
    terms.forEach((t) => {
        let tmp = t.split(" ");
        term.push({type: tmp[0], value: tmp[1]});
    });
    

    privacies.forEach((p) => {
        privacy.push(p.split(" "));
    });
    
    privacy.forEach((p) => {
        const value = term.filter((t) => t.type === p[1]);
        let tmp = new Date(p[0]);
        tmp = new Date(tmp.setMonth(tmp.getMonth() + Number(value[0].value)));
        tmp = new Date(tmp.setDate(tmp.getDate() - 1));
        expiration.push(tmp);
    });
        
    answer = [];
    
    expiration.forEach((e, index) => {
        // 현재 - 과거 => 양수
        // 현재 - 미래 => 음수
       const calc = today - e;
        if(calc > 0) {
            answer.push(index+1);
        }
    });
    
    return answer;
}
728x90

숫자 문자열과 영단어

https://school.programmers.co.kr/learn/courses/30/lessons/81301

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

const dic = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];

const dictionary = {
    zero: 0,
    one: 1,
    two: 2,
    three: 3,
    four: 4,
    five: 5,
    six: 6,
    seven: 7,
    eight: 8,
    nine: 9,
}

function solution(s) {
    let answer = 0;
    
    while(Number.isNaN(Number(s))) {
        dic.forEach( d => {
            s = s.replaceAll(d, dictionary[d]);
        });
        break;
    }
    
    return Number(s);
}
728x90

소인수분해

https://school.programmers.co.kr/learn/courses/30/lessons/120852

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

function solution(n) {
    let answer = new Set();
    const flag = true;
    let i = 2;
    while(flag) {
        if(n === 1) break;
        if(n % i === 0 ) {
            answer.add(i);
            n = n/i;
            i=2;
        }
        else {
            i++;
        }
    }
    
    answer = Array.from(answer);
    answer.sort(function(a,b){
        return a - b;
    });
    
    return answer;
}
728x90

시저 암호

https://school.programmers.co.kr/learn/courses/30/lessons/12926

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

function solution(s, n) {
    // a - z: 97~122
    // A - Z: 65~90
    var answer = [];
    s = s.split('');
    s.forEach((d) => {
        let code = d.charCodeAt();
        if(d === ' ') { answer.push(' '); }
        else if(code+n > 122 && code >= 97) {
            answer.push(String.fromCharCode(97+(code+n - 122-1)));
        }
        else if(code+n > 90 && code <= 90) {
            answer.push(String.fromCharCode(65+(code+n - 90-1)));
        }
        else {
            answer.push(String.fromCharCode(code+n));
        }
    })
    
    return answer.join("");
}
728x90

+ Recent posts