[프로그래머스] / [Level 2] / [Python] 테이블 해시 함수
·
Coding Test/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/147354 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(data, col, row_begin, row_end): answer = 0 data = sorted(data, key=lambda x: (x[col-1], -x[0])) for idx, row in enumerate(data[row_begin-1:row_end]): row_sum = 0 for r in row: row_sum += r % (idx+row_begin) an..
[프로그래머스] / [Level 2] / [Python] 혼자 놀기의 달인
·
Coding Test/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/131130 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(cards): group = [] visited = [False for _ in range(len(cards)+1)] for num in cards: if not visited[num]: temp = [] while True: if num in temp: break temp.append(num) visited[num] = True num = cards[num-1] grou..
[프로그래머스] / [Level 2] / [Python] 시소 짝꿍
·
Coding Test/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/152996 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 다음과 같이 조합을 사용하면 시간 초과 에러를 출력한다. 더보기 from itertools import combinations as c def solution(weights): answer = 0 weights = sorted(weights) ratios = [1/1, 1/2, 2/3, 3/4] for w in list(c(weights, 2)): a, b = w if a/b in ratios:..
[프로그래머스] / [Level 2] / [Python] 마법의 엘레베이터
·
Coding Test/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/148653 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(storey): answer = 0 while storey: mod = storey % 10 if mod > 5: _add = 10 - mod storey += _add answer += _add elif mod 50: stor..
[Python] / [pafy] Youtube 영상 처리
·
Python/모듈 & 패키지 & 라이브러리
pafy https://github.com/mps-youtube/pafy GitHub - mps-youtube/pafy: Python library to download YouTube content and retrieve metadata Python library to download YouTube content and retrieve metadata - GitHub - mps-youtube/pafy: Python library to download YouTube content and retrieve metadata github.com How to use ? 다음과 같이 instance를 선언한 뒤 필요한 정보를 얻을 수 있다. import pafy url = "https://www.youtube.com..
[Python] / [Poetry] 설치 & 간단한 실습 (FastAPI)
·
Python/Setting
https://python-poetry.org/ Poetry - Python dependency management and packaging made easy Dependency resolver Poetry comes with an exhaustive dependency resolver, which will always find a solution if it exists. And get a detailed explanation if no solution exists. Isolation Poetry either uses your configured virtualenvs or creates its own to al python-poetry.org Poetry Python Dependecy Manager로 P..
[프로그래머스] / [Level 2] / [Python] 호텔 대실
·
Coding Test/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/155651 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 주의할 점으로 한 번 사용한 객실은 퇴실 시간을 기준으로 10분간 청소를 하고 다음 손님들이 사용할 수 있습니다. 조건을 확인해야 한다. from collections import deque def solution(book_time): room = [] book_time = [[int(b[0][:2])*60+int(b[0][-2:]), int(b[1][:2])*60+int(b[1][-2:])] ..
[프로그래머스] / [Level 2] / [Python] 무인도 여행
·
Coding Test/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/154540 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 전형적인 DFS/BFS 문제이다. 주의할 점으로 Python에서 기본적으로 재귀 함수의 깊이가 제한(RecursionError)이 되어 있어 이를 해제해야 한다. import sys sys.setrecursionlimit(10**5) def solution(maps): answer = [] row, col = len(maps), len(maps[0]) maps = [list(map) for ma..
욱근욱
개미는 오늘도 열심히 일을하네