전체 글

str변환 활용 [브루트 포스]n = int(input())count = 0for i in range(n + 1): for j in range(60): for k in range(60): if '3' in str(i) + str(j) + str(k): count += 1print(count)  int형만 사용 [경우의 수 줄이기]n = int(input())count = 0for hour in range(n + 1): if hour % 10 == 3 or hour // 10 == 3: count += 60*60 continue for min in range(60): if min % 10 == ..
상하좌우 [ y, x 분리 ]n = int(input())a = list(input().split())posX, posY = 1, 1move = ['L', 'R', 'U', 'D']dx = [-1, 1, 0, 0]dy = [0, 0, -1, 1]for i in a: k = move.index(i) if posX + dx[k]    왕실의 나이트 [ y, x 형식 ]current_pos = input()row = int(current_pos[1])col = int(ord(current_pos[0]) - int(ord('a'))) + 1count = 0steps = [(-2, -1), (-2, 1), (-1, 2), (1, 2), (2, 1), (2, -1), (1, -2),(-1, -2)]for..
· 코테/Solve
n, k = map(int, input().split())result = 0while True: target = (n // k) * k result += (n - target) n = target if n
from collections import Countercounter = Counter(['red', 'blue', 'red', 'green', 'blue', 'blue'])print(counter['blue']) # 'blue'가 등장한 횟수 출력print(dict(counter)) # 사전 자료형으로 반환
import heapqdef heapsort(iterable): h = [] result = [] for value in iterable: heapq.heappush(h, value) for _ in range(len(h)): result.append(heapq.heappop(h)) return resultresult = heapsort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])print(result)  최대 힙import heapqdef heapsort_max(iterable): h = [] result = [] for value in iterable: heapq.heappush(h, -value) fo..
from itertools import permutationsdata2 = ['A', 'B', 'C']result2 = list(permutations(data2, 3)) # 서로 다른 n개에서 서로 다른 r개를 선택하여 일렬로 나열하는 것print(result2)from itertools import combinationsresult2 = list(combinations(data2, 2))print(result2)from itertools import productresult = list(product(data2, repeat=2)) # 두개를 뽑는 모든 순열 구하기 (중복허용)print(result)from itertools import combinations_with_replacement # 두개를..
류가든
장난감정원