Created
February 26, 2014 05:26
-
-
Save tora16e/9223996 to your computer and use it in GitHub Desktop.
roman-numerals
This file contains hidden or 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
| def checkio(data): | |
| def make_rn(i, v, x): | |
| rn = [i*n for n in range(4)] | |
| rn.append(i+v) | |
| rn.append(v) | |
| rn += [v+i*n for n in range(1,4)] | |
| rn.append(i+x) | |
| return rn | |
| Roman = [make_rn("I", "V", "X"), | |
| make_rn("X", "L", "C"), | |
| make_rn("C", "D", "M"), | |
| make_rn("M", "", "")[:4]] | |
| nums = [int(i) for i in reversed(str(data))] | |
| return "".join(reversed([Roman[i][nums[i]] for i in range(len(nums))])) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
なんかごちゃごちゃしたの多かった
ゼロになるまで処理するとか