[프로그래머스] / [Level 2] / [Python] 예상 대진표
·
Coding Test/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/12985 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(n,a,b): answer = 1 for _ in range(n//2): answer += 1 if (abs(a-b) == 1) and (a//2 != b//2): break if a % 2 != 0 or a == 1: if (abs(a-b) == 1) and (a//2 != b//2): break a = (a + 1) if b % 2 != 0 or b == 1: if (a..
[프로그래머스] / [Level 2] / [Python] k진수에서 소수 개수 구하기
·
Coding Test/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/92335 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import math def is_prime(n): for i in range(2, int(math.sqrt(n)+1)): if n % i == 0: return False return True def solution(n, k): answer = 0 # 진수 변환 k_ = '' while n != 0: n, m = divmod(n, k) k_ += str(m) k = k_[::-1] s = k.s..
[프로그래머스] / [Level 2] / [Python] [3차] 압축
·
Coding Test/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/17684 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(msg): """ LZW(Lempel–Ziv–Welch) 1. 길이가 1인 모든 단어를 포함하도록 사전을 초기화한다. 2. 사전에서 현재 입력과 일치하는 가장 긴 문자열 w를 찾는다. 3. w에 해당하는 사전의 색인 번호를 출력하고, 입력에서 w를 제거한다. 4. 입력에서 처리되지 않은 다음 글자가 남아있다면(c), w+c에 해당하는 단어를 사전에 등록한다. 5. 단계 2로..
[프로그래머스] / [Level 2] / [Python] 주차 요금 계산
·
Coding Test/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/92341 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 오랜만에 다시 풀었는데 예전 코드랑 거의 비슷해서 신기했다. from collections import defaultdict from collections import deque import math def solution(fees, records): answer = [] rd = defaultdict(list) # records dict for record in records: t, n, s =..
[프로그래머스] / [Level 2] / [Python] 리코쳇 로봇
·
Coding Test/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/169199 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(board): answer = 0 visited = [] row, col = len(board), len(board[0]) for i in range(row): visited.append([0 for _ in range(col)]) for j in range(col): if board[i][j]=='R': rx, ry = i, j if board[i][j]=='G': gx..
[프로그래머스] / [Level 1] / [Python] 삼총사
·
Coding Test/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/131705 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr from itertools import combinations as cb def solution(number): answer = 0 for c in cb(number, 3): if sum(c) == 0: answer += 1 return answer
[프로그래머스] / [Level 1] / [Python] 크기가 작은 부분 문자열
·
Coding Test/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/147355 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(t, p): answer = 0 for i in range(len(t)-len(p)+1): if int(t[i:i+len(p)])
[프로그래머스] / [Level 2] / [Python] [1차] 캐시
·
Coding Test/프로그래머스
https://school.programmers.co.kr/learn/courses/30/lessons/17680 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(cacheSize, cities): answer = 0 cachelist = [] cache_hit = 1 cache_miss = 5 # 조건 - 대소문자 구문 X & 최대 20자 cities = [city.lower() for city in cities] for city in cities: if city not in cachelist: cachelist.append(cit..
욱근욱
'Coding Test/프로그래머스' 카테고리의 글 목록 (7 Page)