Skip to main content
added 173 characters in body
Source Link
0xffcourse
  • 2.8k
  • 3
  • 14
  • 27

Python 3, 100 97 96 94 93 91 9190 bytes

  • saved 4+2 bytes: use of def; array as default parameter reduced an indentation space; unwanted variable declaration removed
  • @shooqie saved 1 byte a%= shorthand
  • saved 2 bytes: rearranged and braces in (a//i) got removed
  • @Wondercricket saved 1 byte: move the array from default parameter to within the function which removed [] at the cost of one indentation space, thus saving 1 byte.
def f(a,b=[1000):
 b=1000,500,100,50,10,5,1]):1
 for i in b:print(end=a//i*'MDCLXVI'[b.index(i)]);a%=i

Try it online!Try it online!

Python 3, 100 97 96 94 93 91 bytes

  • saved 4+2 bytes: use of def; array as default parameter reduced an indentation space; unwanted variable declaration removed
  • @shooqie saved 1 byte a%= shorthand
  • saved 2 bytes: rearranged and braces in (a//i) got removed
def f(a,b=[1000,500,100,50,10,5,1]):
 for i in b:print(end=a//i*'MDCLXVI'[b.index(i)]);a%=i

Try it online!

Python 3, 100 97 96 94 93 91 90 bytes

  • saved 4+2 bytes: use of def; array as default parameter reduced an indentation space; unwanted variable declaration removed
  • @shooqie saved 1 byte a%= shorthand
  • saved 2 bytes: rearranged and braces in (a//i) got removed
  • @Wondercricket saved 1 byte: move the array from default parameter to within the function which removed [] at the cost of one indentation space, thus saving 1 byte.
def f(a):
 b=1000,500,100,50,10,5,1
 for i in b:print(end=a//i*'MDCLXVI'[b.index(i)]);a%=i

Try it online!

added 62 characters in body
Source Link
0xffcourse
  • 2.8k
  • 3
  • 14
  • 27

Python 3, 100 97 96 94 93 9391 bytes

  • saved 4+2 bytes: use of def; array as default parameter reduced an indentation space; unwanted variable declaration removed
  • @shooqie saved 1 byte a%= shorthand
  • saved 2 bytes: rearranged and braces in (a//i) got removed
def f(a,b=[1000,500,100,50,10,5,1]):
 for i in b:print(end='MDCLXVI'[bend=a//i*'MDCLXVI'[b.index(i)]*(a//i)]);a%=i

Try it online!Try it online!

Python 3, 100 97 96 94 93 bytes

  • saved 4+2 bytes: use of def; array as default parameter reduced an indentation space; unwanted variable declaration removed
  • @shooqie saved 1 byte a%= shorthand
def f(a,b=[1000,500,100,50,10,5,1]):
 for i in b:print(end='MDCLXVI'[b.index(i)]*(a//i));a%=i

Try it online!

Python 3, 100 97 96 94 93 91 bytes

  • saved 4+2 bytes: use of def; array as default parameter reduced an indentation space; unwanted variable declaration removed
  • @shooqie saved 1 byte a%= shorthand
  • saved 2 bytes: rearranged and braces in (a//i) got removed
def f(a,b=[1000,500,100,50,10,5,1]):
 for i in b:print(end=a//i*'MDCLXVI'[b.index(i)]);a%=i

Try it online!

added 26 characters in body
Source Link
0xffcourse
  • 2.8k
  • 3
  • 14
  • 27

Python 3, 100 97 96 94 9493 bytes

  • saved 44+2 bytes: use of def; array as default parameter reduced an indentation space
  • saved 2 bytes:space; unwanted variable declaration removed
  • @shooqie saved 1 byte a%= shorthand
def f(a,b=[1000,500,100,50,10,5,1]):
 for i in b:print(end='MDCLXVI'[b.index(i)]*(a//i));a=a%i;a%=i

Try it online!Try it online!

Python 3, 100 97 96 94 bytes

  • saved 4 bytes: use of def; array as default parameter reduced an indentation space
  • saved 2 bytes: unwanted variable declaration removed
def f(a,b=[1000,500,100,50,10,5,1]):
 for i in b:print(end='MDCLXVI'[b.index(i)]*(a//i));a=a%i

Try it online!

Python 3, 100 97 96 94 93 bytes

  • saved 4+2 bytes: use of def; array as default parameter reduced an indentation space; unwanted variable declaration removed
  • @shooqie saved 1 byte a%= shorthand
def f(a,b=[1000,500,100,50,10,5,1]):
 for i in b:print(end='MDCLXVI'[b.index(i)]*(a//i));a%=i

Try it online!

added 43 characters in body
Source Link
0xffcourse
  • 2.8k
  • 3
  • 14
  • 27
Loading
added 43 characters in body
Source Link
0xffcourse
  • 2.8k
  • 3
  • 14
  • 27
Loading
Source Link
0xffcourse
  • 2.8k
  • 3
  • 14
  • 27
Loading