-
다단계 칫솔 판매코딩 테스트/Level 3 2021. 5. 5. 09:25반응형
다단계 칫솔 판매
2021 Dev-Matching: 웹 백엔드 개발자(상반기)
238명 완료programmers.co.kr/learn/courses/30/lessons/77486
def solution(enroll, referral, seller, amount): tree = {} income = {} for member, referee in zip(enroll, referral): tree[member] = referee income[member] = 0 for index, member in enumerate(seller): money1 = amount[index] * 100 money2 = money1 // 10 referee = tree[member] income[member] += money1 - money2 while referee != '-': money1 = money2 money2 = money1 // 10 income[referee] += money1 - money2 referee = tree[referee] return [income[each] for each in enroll]
반응형