본문 바로가기

파이썬50

PCCP 기출문제 > 붕대 감기 - Pyton, 구현 https://school.programmers.co.kr/learn/courses/30/lessons/250137 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드 & 풀이 def solution(bandage, health, attacks): max_health = health bonus_standard, heal_per_sec, bonus_heal = bandage for i in range(len(attacks)): if i == 0: health -= attacks[i][1] else: gap = attacks[.. 2024. 12. 8.
2021 KAKAO BLIND RECRUITMENT > 신규 아이디 추천 - Python, 정규표현식 https://school.programmers.co.kr/learn/courses/30/lessons/72410 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드 import redef solution(new_id): new_id = re.sub(r'[^a-z0-9_.-]', '', new_id.lower()) new_id = re.sub(r'\.{2,}', '.', new_id).strip('.') new_id = "aaa" if not new_id else new_id[:15].rstrip('.') return new_id.ljust(3, new_id[-1])  정규표현식을.. 2024. 12. 7.
PCCE 기출문제 > 데이터 분석 - Pyton, sorted, lambda https://school.programmers.co.kr/learn/courses/30/lessons/250121 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드 def solution(data, ext, val_ext, sort_by): compiles = {"code" : 0, "date" : 1, "maximum" : 2, "remain" : 3} ext_index = compiles[ext] sort_index = compiles[sort_by] filtered_data = [row for row in data if row[ext_index]   줄이려면 한 줄.. 2024. 12. 7.
2018 KAKAO BLIND RECRUITMENT > 다트 게임 - Pyton, re, compile, findall, 정규식 https://school.programmers.co.kr/learn/courses/30/lessons/17682 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드def solution(dartResult): num = "" score = [] bonus = {"S":1, "D":2, "T":3} for round in dartResult: if round.isdigit(): num += round elif round in bonus: score.append(int(num) ** bonus[round].. 2024. 12. 6.
2018 KAKAO BLIND RECRUITMENT > 비밀지도 - Pyton, n진법, bin, zfill https://school.programmers.co.kr/learn/courses/30/lessons/17681 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 풀이 - 나의 생각    코드 def solution(n, arr1, arr2): answer = [] def to_binary(num): digit = [] cnt = n while cnt > 0: digit.append(num%2) num //= 2 cnt -= 1 return ''.join(str(x) for x .. 2024. 12. 5.
월간 코드 챌린지 시즌1 > 두 개 뽑아서 더하기 - Python, combinations(조합) https://school.programmers.co.kr/learn/courses/30/lessons/68644 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr  코드 & 풀이 from itertools import combinationsdef solution(numbers): return sorted({a+b for a, b in combinations(numbers, 2)})  콤비네이션을 사용해서 풀어봤습니다. def solution(numbers): return sorted({numbers[i] + numbers[j] for i in range(len(numbers)) for j in.. 2024. 12. 5.