본문 바로가기
프로그래밍 문제/[Python] CheckIO

[Check-IO] Follow Instructions

by UltraLowTemp-Physics 2021. 12. 18.
728x90

[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')
728x90

'프로그래밍 문제 > [Python] CheckIO' 카테고리의 다른 글

[Check-IO] Conversion from CamelCase  (0) 2021.12.20
[Check-IO] The Most Wanted Letter  (0) 2021.12.19
[Check-IO] Common Words  (0) 2021.12.16
[Check-IO] Sum by Type  (0) 2021.12.12
[Check-IO] Time converter  (0) 2021.12.10

댓글