# python test

cjh2626002·2022년 6월 27일
0
# hash
def solution(participant, completion):
dict = {}
sum = 0

for part in participant:
print(hash(part))
dict[hash(part)] = part
sum += hash(part)
for comp in completion:
sum -= hash(comp)

return dict[sum]
# hash num
def solution(phone_book):
dict = {}
for num in phone_book:
dict[num] = 1

for num in phone_book:
a = ""
for n in num:
a += n
if a in dict and a != num:
return False
return True

# 위장
def solution(clothes):
hash_map = {}
for clothe, type in clothes:
hash_map[type] = hash_map.get(type, 0) + 1

for type in hash_map:

# progress
import math

def solution(progresses, speeds):

days = [math.ceil((100-p)/s) for p, s in zip(progresses, speeds)]
idx = 0

for i in range(len(days)):
if days[idx] < days [i]:
idx = i

# printer queue
def solution(priorities, location):
queue =  [(i,p) for i,p in enumerate(priorities)]
print(queue)
while True:
cur = queue.pop(0)
if any(cur[1] < q[1] for q in queue):
queue.append(cur)
else:
if cur[0] == location:

# 완전탐색
list1 = [1, 2, 3, 4, 5]
list2 = [2, 1, 2, 3, 2, 4, 2, 5]
list3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]
score = [0,0,0]
score[0] += 1
score[1] += 1
score[2] += 1
for i, s in enumerate(score):
if s == max(score):

# 카펫
def solution(brown, yellow):
total = brown + yellow
for b in range(1,total+1):
if (total / b) % 1 == 0:
a = total / b
if a >= b:
if (a-2)*(b-2) == yellow:
return [a,b]

# target number
def solution(numbers, target):
queue = [[numbers[0],0], [-1*numbers[0],0]]
n = len(numbers)
while queue:
print(queue)
temp, idx = queue.pop()
print(temp, idx)
idx += 1
if idx < n:
queue.append([temp+numbers[idx], idx])
queue.append([temp-numbers[idx], idx])
else:
if temp == target:
return answer