Skip to content

Instantly share code, notes, and snippets.

@trsqxyz
Created February 26, 2014 05:26
Show Gist options
  • Save trsqxyz/9223996 to your computer and use it in GitHub Desktop.
Save trsqxyz/9223996 to your computer and use it in GitHub Desktop.
roman-numerals
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))]))
@trsqxyz
Copy link
Author

trsqxyz commented Feb 26, 2014

なんかごちゃごちゃしたの多かった
ゼロになるまで処理するとか

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment