Skip to content

Instantly share code, notes, and snippets.

@ReeceHub
Last active January 23, 2019 17:58
Show Gist options
  • Save ReeceHub/b5b1ba8376bdaa6a97fa232608c53da9 to your computer and use it in GitHub Desktop.
Save ReeceHub/b5b1ba8376bdaa6a97fa232608c53da9 to your computer and use it in GitHub Desktop.
def add(first, second):
smooshed = ''.join(sorted(first + second, reverse=True))
smooshed = smooshed.replace('IIIII', 'V')
smooshed = smooshed.replace('VV', 'X')
smooshed = smooshed.replace('XXXXX', 'L')
return smooshed
from roman_numerals import add
import pytest
def test_one_plus_one():
assert add('I', 'I') == 'II'
def test_one_plus_two():
assert add('I', 'II') == 'III'
assert add('II', 'I') == 'III'
def test_three_plus_two():
assert add('III', 'II') == 'V'
def test_five_plus_one():
assert add('V', 'I') == 'VI'
def test_five_plus_file():
assert add('V', 'V') == 'X'
def test_seven_plus_three():
assert add('VII', 'III') == 'X'
def test_thirty_plus_twenty():
assert add('XXX', 'XX') == 'L'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment