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

 

프로그래머스

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

programmers.co.kr

function factorial(n) {
    let result = 1;
    for(let i = 2 ; i <= n ; i++) {
        result *= i;
    }
    return result;
}

function solution(balls, share) {
    const n_ = factorial(balls); // n!
    const m_ = factorial(share); // m!
    const n_m = factorial(balls-share); // (n-m)!
    
    return Math.round((n_)/(n_m * m_));   
}
728x90

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

 

프로그래머스

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

programmers.co.kr

function solution(M, N) {
    var answer = 0;
    if(M === 1 && N === 1) return 0;
    
    return (M*N)-1;
}
728x90

https://www.acmicpc.net/problem/9093

 

9093번: 단어 뒤집기

첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있으며, 문장이 하나 주어진다. 단어의 길이는 최대 20, 문장의 길이는 최대 1000이다. 단어와 단어 사이에는

www.acmicpc.net

const fs = require('fs');
const input = fs.readFileSync('/dev/stdin').toString().split("\n");

const N = Number(input[0])

for(let i = 1 ; i <= N ; i++) {
    const string = input[i].split(" ");
    string.forEach((s, index) => {
        const tmp = s.split("");
        tmp.reverse();
        string[index] = tmp.join("");
    });
    console.log(string.join(" "));
};
728x90

https://www.acmicpc.net/problem/10808

 

10808번: 알파벳 개수

단어에 포함되어 있는 a의 개수, b의 개수, …, z의 개수를 공백으로 구분해서 출력한다.

www.acmicpc.net

const fs = require('fs');
const input = fs.readFileSync('/dev/stdin').toString().trim().split("");
const answer = [];

const dic = {
    a: 0,
    b: 0,
    c: 0,
    d: 0,
    e: 0,
    f: 0,
    g: 0,
    h: 0,
    i: 0,
    j: 0,
    k: 0,
    l: 0,
    m: 0,
    n: 0,
    o: 0,
    p: 0,
    q: 0,
    r: 0,
    s: 0,
    t: 0,
    u: 0,
    v: 0,
    w: 0,
    x: 0,
    y: 0,
    z: 0,
}

input.forEach((d) => {
    if(dic[d] !== undefined ) dic[d]++;
});

const keyList = Object.keys(dic);

keyList.forEach((key) => {
    answer.push(dic[key]);
});

console.log(answer.join(" "));
728x90

+ Recent posts