diff --git a/.github/action.yml b/.github/action.yml new file mode 100644 index 0000000..91a36c1 --- /dev/null +++ b/.github/action.yml @@ -0,0 +1,8 @@ +name: Our First Workflow +run-name: Bae is testing out GitHub Actions πŸš€ +on: push +jobs: + echo: + runs-on: ubuntu-latest + steps: + - run: echo 'Hello, GitHub Actions!' \ No newline at end of file diff --git a/kakak_2023_blind/delivery_box.py b/kakak_2023_blind/delivery_box.py new file mode 100644 index 0000000..363302a --- /dev/null +++ b/kakak_2023_blind/delivery_box.py @@ -0,0 +1,78 @@ +def get_longest_site(site, n): + move = 0 + + for point_idx in range(n, -1, -1): + if site[point_idx] > 0: + move = point_idx + break + + return move + +def caculate_spend_day(deliveries, cap): + needed_day = [0] * len(deliveries) + n = len(deliveries) + max_cap = cap + day = 1 + + site_idx = n - 1 + + while 0 <= site_idx: + if deliveries[site_idx] == 0: + site_idx -= 1 + continue + + #이번 μž₯μ†Œμ— μžˆλŠ” 물건은 μΆ©λΆ„νžˆ 닀을 수 있음 + if deliveries[site_idx] <= cap: + cap -= deliveries[site_idx] + deliveries[site_idx] = 0 + needed_day[site_idx] = day + + #이번 μž₯μ†Œμ— μžˆλŠ” 물건은 담을 수 μ—†μŒ + else: + deliveries[site_idx] = deliveries[site_idx] - cap #λ‹Ήλ―ˆ 수 μžˆλŠ” 만큼 λ‹΄μ•„μ„œ 좜발 + day += 1 + cap = max_cap + + return needed_day + +def calculated_move(result, n): + answer = 0 + spended_day = 0 + + for i in range(n, 0, -1): + day = result[i] - spended_day + + if day <= 0: + continue + + spended_day += day + print(i) + answer += day * (i * 2) + + return answer + +def solution(cap, n, deliveries, pickups): + answer = 0 + + deliveries.insert(0, 0) + pickups.insert(0, 0) + + calc_delivers = caculate_spend_day(deliveries, cap) + calc_pickups = caculate_spend_day(pickups, cap) + + result = [] + + for i in range(len(calc_delivers)): + result.append(max(calc_delivers[i], calc_pickups[i])) + + answer = calculated_move(result, n) + return answer + +if __name__ == "__main__": + cap = 4 + n = 6 + deliveries =[1, 0, 3, 1, 2, 0] + pickups = [0, 3, 0, 4, 0, 1] + result = 16 + + print(solution(cap, n, deliveries, pickups)) \ No newline at end of file diff --git a/kakak_2023_blind/find_route.py b/kakak_2023_blind/find_route.py new file mode 100644 index 0000000..035489d --- /dev/null +++ b/kakak_2023_blind/find_route.py @@ -0,0 +1,46 @@ +import heapq +from collections import defaultdict + +def check_is_out_range(n_y, m_x, y, x): + if (1 <= y <= n_y) and (1 <= x <= m_x): + return False + return True + +def solution(n_y, m_x, x, y, r, c, k): + y, x = x, y + + my = [-1, 0, 1, 0] + mx = [0, 1, 0, -1] + dir = ['u','r', 'd', 'l'] + + heap = [] + heapq.heappush(heap, ["", y , x]) + + while heap: + state, y, x = heapq.heappop(heap) + dist = abs(r - y) + abs(c - x) #μ΅œλ‹¨κ±°λ¦¬ + remain = k - len(state) + + if (remain - dist) % 2 is 1: + continue + + if [y, x] == [r, c]: + if remain is 0: + return state + + if dist > remain: + continue + + for d_y, d_x, d in zip(my, mx, dir): + r_y = y + d_y + r_x = x + d_x + r_state = state + d + + if not check_is_out_range(n_y, m_x, r_y, r_x): + heapq.heappush(heap, [r_state, r_y, r_x]) + + return "impossible" + +if __name__ == "__main__": + n, m, x, y, r, c, k = [3, 4, 2 , 3 , 3, 1 ,5] + print(solution(n, m, x, y, r, c, k)) \ No newline at end of file diff --git a/kakak_2023_blind/imoji.py b/kakak_2023_blind/imoji.py new file mode 100644 index 0000000..fb1ca88 --- /dev/null +++ b/kakak_2023_blind/imoji.py @@ -0,0 +1,38 @@ +from itertools import product + +def solution(users, emoticons): + answer = [0, 0] + discount = [0.1, 0.2, 0.3, 0.4] + + for pick in product(discount, repeat=len(emoticons)): + + can_get_moeny = 0 + join_emoji_club = 0 + + for user in users: + discount_need = user[0] / 100 + upper_limit = user[1] + total_money = 0 + + for sale, price in zip(pick, emoticons): + if discount_need <= sale: + total_money += price * (1 - sale) + + if upper_limit <= total_money: + total_money = 0 + join_emoji_club += 1 + + can_get_moeny += total_money + + answer = max(answer, [join_emoji_club, can_get_moeny]) + + return answer + + + +if __name__ == "__main__": + users = [[40, 10000], [1, 10000]] + emoticons = [7000, 9000] + result = [1, 5400] + + print(solution(users, emoticons)) diff --git a/kakak_2023_blind/info_human.py b/kakak_2023_blind/info_human.py new file mode 100644 index 0000000..8d61b50 --- /dev/null +++ b/kakak_2023_blind/info_human.py @@ -0,0 +1,38 @@ +def y_to_day(year): + return year * 336 + +def m_to_day(month): + return month * 28 + +def get_day(today): + year, month, day = map(int, today.split(".")) + return y_to_day(year) + m_to_day(month) + day + +def solution(today, terms, privacies): + answer = [] + doc = {} + + today = get_day(today) + + for i in terms: + type_doc, mon_dur = i.split() + doc[type_doc] = int(mon_dur) + + for i in range(len(privacies)): + day, type_doc = privacies[i].split() + duration = doc[type_doc] + + expire_time = get_day(day) + m_to_day(duration) + + if expire_time <= today: + answer.append(i + 1) + + return answer + + +if __name__ == "__main__": + today = "2022.05.19" + terms = ["A 6", "B 12", "C 3"] + privacies = ["2021.05.02 A", "2021.07.01 B", "2022.02.19 C", "2022.02.20 C"] + + print(solution(today, terms, privacies)) \ No newline at end of file