Last active
December 26, 2015 00:29
-
-
Save ziozzang/7064713 to your computer and use it in GitHub Desktop.
http://www.synapsoft.co.kr/jsp/recruit/13_apply.html
사이냅 소프트쪽의 테스트 코드를
파이썬으로 얼마나 짧게 짤 수 있을까 해서 만든 코드
사실 C/C++ 로 짜도 그게 그거...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# - Code by Jioh L. Jung - | |
# - [email protected] | |
# | |
# Python Code for synapsoft test. / just for fun.! yeah! | |
# http://www.synapsoft.co.kr/jsp/recruit/13_apply.html | |
# | |
def c(n,s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"): | |
return (((n-1) < 26) and s[n-1]) or (c((n-1) // 26) + s[(n-1) % 26]) | |
""" | |
Example | |
>>> c(1) | |
'A' | |
>>> c(26) | |
'Z' | |
>>> c(27) | |
'AA' | |
>>> c(28) | |
'AB' | |
>>> c(52) | |
'AZ' | |
>>> c(53) | |
'BA' | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
빈칸 없애고, s를 chr(64+n) 함수로 바꾸면 더 줄어 들듯.