나는 이렇게 학습한다/Algorithm & SQL

0115. Name on billboard

daco2020 2023. 1. 15. 19:09
반응형

You can print your name on a billboard ad. Find out how much it will cost you. Each character has a default price of £30, but that can be different if you are given 2 parameters instead of 1.

You can not use multiplier "*" operator.

If your name would be Jeong-Ho Aristotelis, ad would cost £600. 20 leters * 30 = 600 (Space counts as a character).



Solution:

def billboard(name, price=30):
    return sum(price for _ in name)


반응형

'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글

0117. get character from ASCII Value  (0) 2023.01.18
0116. OOP: Object Oriented Piracy  (0) 2023.01.16
0114. Are arrow functions odd?  (0) 2023.01.15
0113. Build a square  (0) 2023.01.13
0112. Tip Calculator  (0) 2023.01.13