프로그래밍 문제/[Python] CheckIO
[Check-IO] Follow Instructions
UltraLowTemp-Physics
2021. 12. 18. 14:50
[1] Problems: https://py.checkio.org/en/mission/follow-instructions/
[2] My solutions
def follow(instructions: str) -> Tuple[int, int]:
# your code here
f = instructions.count('f')
b = instructions.count('b')
l = instructions.count('l')
r = instructions.count('r')
return (- l + r, -b +f )
[3] Good solutions
def follow(instructions):
c = instructions.count
return c('r') - c('l'), c('f') - c('b')