Skip to content

Instantly share code, notes, and snippets.

@tora16e
Created February 26, 2014 05:26
Show Gist options
  • Select an option

  • Save tora16e/9223996 to your computer and use it in GitHub Desktop.

Select an option

Save tora16e/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))]))
@tora16e

tora16e commented Feb 26, 2014

Copy link
Copy Markdown
Author

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

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