코딩 테스트/Level 1
-
프로그래머스 / 햄버거 만들기코딩 테스트/Level 1 2022. 10. 27. 23:25
https://school.programmers.co.kr/learn/courses/30/lessons/133502 파이썬 def solution(ingredient): stack = [] answer = 0 for each in ingredient: stack.append(each) if stack[-4:] == [1, 2, 3, 1]: answer += 1 del stack[-4:] return answer 코틀린 class Solution { fun solution(ingredient: IntArray): Int { var answer = 0 val bugger = listOf(1, 2, 3, 1) val stack = mutableListOf() for (each in ingredient) { s..
-
프로그래머스 / 옹알이 (2)코딩 테스트/Level 1 2022. 10. 27. 23:16
https://school.programmers.co.kr/learn/courses/30/lessons/133499 파이썬 def solution(babbling): answer = 0 for each in babbling: for index, text in enumerate(("aya", "ye", "woo", "ma")): each = each.replace(text, str(index)) if each.isdigit(): if '00' not in each: if '11' not in each: if '22' not in each: if '33' not in each: answer += 1 return answer 코틀린 class Solution { fun solution(babbling: Arr..
-
프로그래머스 / 콜라 문제코딩 테스트/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_..