Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions hwangheetae/Pre-Season/240527/가장 많이 받은 선물.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def solution(friends, gifts):
gifted = {}
gift_idx = {}
for friend in friends:
gifted[friend] = {}
gift_idx[friend] = 0

for gift in gifts:
t, f = gift.split(' ')
if f in gifted[t]:
gifted[t][f] += 1
else:
gifted[t][f] = 1
gift_idx[t] += 1
gift_idx[f] -= 1

will_get = [0 for _ in friends]
for i in range(len(friends)):
curr = friends[i]
for j in range(i+1, len(friends)):
another = friends[j]
a = gifted[curr][another] if another in gifted[curr] else 0
b = gifted[another][curr] if curr in gifted[another] else 0

if a > b:
will_get[i] += 1
elif a < b:
will_get[j] += 1
elif a == b:
ai, bi = gift_idx[curr], gift_idx[another]
if ai > bi:
will_get[i] += 1
elif ai < bi:
will_get[j] += 1

answer = max(will_get)
return answer
41 changes: 41 additions & 0 deletions hwangheetae/Pre-Season/240528/붕대 감기.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
def solution(bandage, health, attacks):
bandage_time=bandage[0]
heal_per_time=bandage[1]
bonus_heal = bandage[2]
default_health= health
total_time = attacks[-1][0]
heal_continue=-1
damage_time= []
damage_amount=[]

for item in attacks:
damage_time.append(item[0])
damage_amount.append(item[1])

j=0
for i in range(total_time+1):
if i == damage_time[j] :
health-=damage_amount[j]
j+=1

heal_continue=0
if health<=0:
return -1

else:
health+=heal_per_time
heal_continue+=1

if heal_continue==bandage_time:
health+=bonus_heal
heal_continue=0

if health>default_health:
health=default_health
print('time:', i )
print(health)
print('heal_continue:', heal_continue)
return health



15 changes: 15 additions & 0 deletions hwangheetae/Pre-Season/240529/이웃한 칸.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def solution(board, h, w):
n= len(board)
count =0
# 우 하 상 좌
dh = [0, 1, -1, 0]
dw = [1, 0, 0, -1]

for i in range(4):
h_check = h+dh[i]
w_check =w+dw[i]
if h_check >=0 and h_check<n and w_check >=0 and w_check<n:
if board[h][w] == board[h_check][w_check]:
count+=1

return count