코딩테스트/LV. 0

LV. 0 :: 개미 군단

KUROMI98 2023. 1. 20. 17:06

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

 

프로그래머스

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

programmers.co.kr

 

function solution(hp) {
    var answer = 0;
    ant1 = Math.floor(hp/5);
    ant2 = Math.floor((hp%5)/3);
    ant3 = Math.floor(((hp%5)%3));
    answer = ant1+ant2+ant3;
    return answer;
}

230525 python

def solution(hp):
    return hp//5 + hp%5//3 + hp%5%3

230915 C++

#include <string>
#include <vector>

using namespace std;

int solution(int hp) { 
int ant1 = hp/5;
int ant2 = (hp%5)/3;
int ant3 = ((hp%5)%3);
    return ant1+ant2+ant3;
}