나는 이렇게 학습한다/Algorithm & SQL
1004. Keep up the hoop
daco2020
2022. 10. 4. 21:01
Alex just got a new hula hoop, he loves it but feels discouraged because his little brother is better than him
Write a program where Alex can input (n) how many times the hoop goes round and it will return him an encouraging message :)
- If Alex gets 10 or more hoops, return the string "Great, now move on to tricks".
- If he doesn't get 10 hoops, return the string "Keep at it until you get it".
Solution:
from functools import lru_cache
def hoop_count(n: int) -> str:
select = n >= 10 and 1 or 0
return _get_encouraging_message(select)
@lru_cache(maxsize=2)
def _get_encouraging_message(select: int) -> str:
return {
1 : "Great, now move on to tricks",
0 : "Keep at it until you get it"
}[select]