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

5 without numbers !!

daco2020 2022. 8. 19. 00:27
반응형

Write a function that always returns 5

Sounds easy right? Just bear in mind that you can't use any of the following characters: 0123456789*+-/

Good luck :)

 

 

Solution:

def unusual_five():
    return int([i for i in str(ord("A"))].pop())

 

 

Other Solution:

def unusual_five():
    return len("five!")

 

def unusual_five():
    return ord("")

 

반응형

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

Flatten and sort an array  (0) 2022.08.20
Find the stray number  (0) 2022.08.19
If you can't sleep, just count sheep!!  (0) 2022.08.17
Row Weights  (0) 2022.08.16
Playing with digits  (0) 2022.08.15