코딩 테스트/Level 1
-
프로그래머스 / 콜라 문제코딩 테스트/Level 1 2022. 10. 27. 23:15
https://school.programmers.co.kr/learn/courses/30/lessons/132267 파이썬 def solution(a, b, n): answer = 0 while n >= a: quotient = n // a # 몫 new_bottle = quotient * b # 새 콜라 n -= a * quotient # 마트에 가져다 준 빈 병 answer += new_bottle n += new_bottle return answer import sys sys.setrecursionlimit(10000) def solution(a, b, n): if n < a: return 0 quotient = n // a new_bottle = quotient * b return new_bott..
-
프로그래머스 / 삼총사코딩 테스트/Level 1 2022. 10. 27. 23:14
https://school.programmers.co.kr/learn/courses/30/lessons/131705 파이썬 억지스럽게... from itertools import combinations solution = lambda number: sum(1 for each in combinations(number, 3) if sum(each) == 0) 정상적으로... from itertools import combinations def solution(number): return sum(1 for each in combinations(number, 3) if sum(each) == 0) 코틀린 class Solution { fun solution(number: IntArray): Int { var a..
-
프로그래머스 / 숫자 짝꿍코딩 테스트/Level 1 2022. 10. 27. 23:13
https://school.programmers.co.kr/learn/courses/30/lessons/131128 파이썬 억지스럽게... from collections import Counter solution = lambda num1, num2: ('0' if (result := ''.join(each * inter_n[each] for each in sorted(inter_n, reverse=True)))[0] == '0' else result) if (inter_n := Counter(list(num1)) & Counter(list(num2))) else "-1" 덜 억지스럽게... from collections import Counter def solution(num1, num2): return..
-
566. Reshape the Matrix코딩 테스트/Level 1 2022. 9. 7. 17:36
https://leetcode.com/problems/reshape-the-matrix/ Reshape the Matrix - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com from typing import List class Solution: def matrixReshape(self, mat: List[List[int]], r: int, c: int) -> List[List[int]]: flat = tuple(each for row in mat for each..
-
[2022 KAKAO TECH INTERNSHIP] 성격 유형 검사하기코딩 테스트/Level 1 2022. 8. 20. 22:21
https://school.programmers.co.kr/learn/courses/30/lessons/118666 파이썬 def solution(survey, choices): d = {} for s, c in zip(survey, choices): if ord(s[0]) < ord(s[1]): d[s] = d.get(s, 0) + (c - 4) else: d[s[::-1]] = d.get(s[::-1], 0) - (c - 4) return ''.join((check('RT', d), check('CF', d), check('JM', d), check('AN', d))) def check(type_, d): return type_[0] if d.get(type_, 0) score2) return typ..
-
[2022 KAKAO BLIND RECRUITMENT] 신고 결과 받기코딩 테스트/Level 1 2022. 1. 17. 01:08
https://programmers.co.kr/learn/courses/30/lessons/92334 코딩테스트 연습 - 신고 결과 받기 문제 설명 신입사원 무지는 게시판 불량 이용자를 신고하고 처리 결과를 메일로 발송하는 시스템을 개발하려 합니다. 무지가 개발하려는 시스템은 다음과 같습니다. 각 유저는 한 번에 한 명의 programmers.co.kr 파이썬 최신 파이썬에선 dict의 순서가 유지됩니다. def solution(id_list, report, k): report_dict = {id_: set() for id_ in id_list} for each in report: user_id, report_id = each.split(' ') report_dict[report_id].add(user_..
-
나머지가 1이 되는 수 찾기코딩 테스트/Level 1 2021. 10. 16. 12:57
https://programmers.co.kr/learn/courses/30/lessons/87389 코딩테스트 연습 - 나머지가 1이 되는 수 찾기 자연수 n이 매개변수로 주어집니다. n을 x로 나눈 나머지가 1이 되도록 하는 가장 작은 자연수 x를 return 하도록 solution 함수를 완성해주세요. 답이 항상 존재함은 증명될 수 있습니다. 제한사항 입 programmers.co.kr 파이썬 def solution(n): for each in range(2, n): if n % each == 1: return each 자바 class Solution { public int solution(int n) { var answer = 2; while (n % answer != 1) answer++; re..
-
위클리 챌린지 8주차: 최소직사각형코딩 테스트/Level 1 2021. 9. 27. 16:31
https://programmers.co.kr/learn/courses/30/lessons/86491 코딩테스트 연습 - 8주차 [[10, 7], [12, 3], [8, 15], [14, 7], [5, 15]] 120 [[14, 4], [19, 6], [6, 16], [18, 7], [7, 11]] 133 programmers.co.kr 파이썬 def solution(sizes): h, v = 0, 0 for a, b in sizes: if a > b: a, b = b, a if h < a: h = a if v < b: v = b return h * v Java class Solution { public int solution(int[][] sizes) { var max_x = 0; var max_y =..