코딩 테스트/Level 1
-
[PCCE 기출문제] 10번 / 데이터 분석코딩 테스트/Level 1 2024. 4. 8. 22:42
https://school.programmers.co.kr/learn/courses/30/lessons/250121 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(data, ext, val_ext, sort_by): cols = {"code": 0, "date": 1, "maximum": 2, "remain": 3} return sorted(filter(lambda x: x[cols[ext]] < val_ext, data), key=lambda x: x[cols[sort_by]]) print(solution( [[1, 2030010..
-
[PCCE 기출문제] 9번 / 이웃한 칸코딩 테스트/Level 1 2024. 4. 3. 14:09
https://school.programmers.co.kr/learn/courses/30/lessons/250125 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(board, h, w): answer = 0 for dh, dw in ((0, 1), (1, 0), (-1, 0), (0, -1)): if 0
-
[PCCP 기출문제] 1번 / 붕대 감기코딩 테스트/Level 1 2024. 4. 3. 11:14
https://school.programmers.co.kr/learn/courses/30/lessons/250137 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(bandage, health, attacks): max_health = health success = 0 attacks_dict = {time: attack for time, attack in attacks} for time in range(1, max(attacks_dict) + 1): if time in attacks_dict: health -= attacks_dict..
-
2024 KAKAO WINTER INTERNSHIP 가장 많이 받은 선물코딩 테스트/Level 1 2024. 4. 3. 09:49
https://school.programmers.co.kr/learn/courses/30/lessons/258712 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 자료 구조까지 예시로 제공되어 풀기 쉽도록 만든 문제.. 매번 friends에서 원소의 위치를 찾는 것은 비효율적이다. 딕셔너리(맵, 해시)를 이용해 O(1)로 위치를 찾도록 하자. def solution(friends, gifts): friend_index = {friend: index for index, friend in enumerate(friends)} gift_table = [[0 fo..
-
프로그래머스 / 달리기 경주코딩 테스트/Level 1 2023. 4. 10. 18:21
https://school.programmers.co.kr/learn/courses/30/lessons/178871 파이썬 def solution(players, callings): players_map = {each: index for index, each in enumerate(players)} for player in callings: index = players_map[player] players_map[player] -= 1 players_map[players[index - 1]] += 1 players[index - 1], players[index] = players[index], players[index - 1] return players 계속 find 명령을 쓰면 시간이 너무 오래 걸린다...
-
프로그래머스 / 추억 점수코딩 테스트/Level 1 2023. 4. 1. 07:47
https://school.programmers.co.kr/learn/courses/30/lessons/176963 파이썬 def solution(name, yearning, photo): scores = {n: s for n, s in zip(name, yearning)} return [sum(scores.get(person, 0) for person in pic) for pic in photo] def solution(name, yearning, photo): return [sum({n: s for n, s in zip(name, yearning)}.get(person, 0) for person in pic) for pic in photo] 코틀린 class Solution { fun solution..
-
프로그래머스 / 공원 산책코딩 테스트/Level 1 2023. 3. 24. 00:01
https://school.programmers.co.kr/learn/courses/30/lessons/172928 파이썬 def solution(park, routes): position = [0, 0] for i, row in enumerate(park): for j, each in enumerate(row): if each == 'S': position = [i, j] directions = {'E': (0, 1), 'W': (0, -1), 'N': (-1, 0), 'S': (1, 0)} for direction, distance in map(lambda x: x.split(), routes): prev_pos = position.copy() for _ in range(int(distance)): ..
-
프로그래머스 / 당구 연습코딩 테스트/Level 1 2023. 3. 17. 11:27
https://school.programmers.co.kr/learn/courses/30/lessons/169198 경계면을 기준으로 '접힌 상태를 편다'라고 생각하면 간단하다.. '피타고라스의 정의'를 이용해 거리를 계산. 파이썬 def solution(m, n, sx, sy, balls): return [ min((sx - x) ** 2 + (sy - y) ** 2 for x, y in ((-bx, by), (bx, -by), (2 * m - bx, by), (bx, 2 * n - by)) if not ((sx == bx and (sy > by > y or sy bx > x or sx < bx < x))) ) for bx, by in bal..