Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arreglo de la primera linea #21

Open
wants to merge 34 commits into
base: arregloDeCodigoPEP8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a6c9245
change array identation
eb-francisco Feb 26, 2018
2f03242
Fixed whitespace around arithmetic operation file roman_to_number lin…
eb-fmezzabotta Feb 26, 2018
16d8775
eliminar dos espacios en blanco del diccionario
agustin18 Feb 26, 2018
3aff876
primer linea arreglada
danteC94 Feb 26, 2018
dd0ada5
Merge pull request #9 from evbeda/whitespaces
eldalai Feb 26, 2018
1f3fb85
Merge pull request #11 from evbeda/two_spaces_before
eldalai Feb 26, 2018
73f87fa
add line 18
PKpacheco Feb 26, 2018
6e9a156
Fixed whitespace line 41 test_roman.py
eb-fmezzabotta Feb 26, 2018
5b1dbe0
Merge pull request #13 from evbeda/rama_dante
eldalai Feb 26, 2018
62feb85
add line 8
PKpacheco Feb 26, 2018
0f03098
Se arreglo el dos puntos del caracter M
agustin18 Feb 26, 2018
3873f79
mend
eb-francisco Feb 26, 2018
7f041fd
Fixed whitespace line 41 test_roman.py
eb-fmezzabotta Feb 26, 2018
95d522a
Fixed line too long test_roman_to_int line 32
eb-fmezzabotta Feb 26, 2018
9090425
Merge pull request #18 from evbeda/update3_pk
eldalai Feb 26, 2018
3369c43
Merge pull request #10 from evbeda/brachIndentArray
eldalai Feb 26, 2018
08d7cb2
Merge pull request #17 from evbeda/100M
eldalai Feb 26, 2018
cccd586
Merge pull request #14 from evbeda/update2_pk
eldalai Feb 26, 2018
19bbf7d
Merge pull request #16 from evbeda/whitespaces1
eldalai Feb 26, 2018
71efccc
900
agustin18 Feb 26, 2018
c595c93
Merge pull request #22 from evbeda/900
eldalai Feb 26, 2018
1d94f5a
Fixed line too long test_roman_to_int line 32
eb-fmezzabotta Feb 26, 2018
c2e52de
Added EOF line to test_suite.py
eb-fmezzabotta Feb 26, 2018
43454a1
spaces500
agustin18 Feb 26, 2018
adcdde4
Merge pull request #25 from evbeda/500
eldalai Feb 26, 2018
968105e
Merge pull request #24 from evbeda/whitespaces3
eldalai Feb 26, 2018
45c1dc4
Merge pull request #20 from evbeda/whitespaces2
eldalai Feb 26, 2018
bcbf379
modify Romany.py
manuelcorrales Feb 26, 2018
696952c
Merge pull request #19 from evbeda/manubranch
eldalai Feb 26, 2018
b173c44
add testing coverage
eldalai Feb 26, 2018
8057380
support coverage
gabrielf-eb Feb 26, 2018
277d084
Merge pull request #28 from evbeda/support-coverage
eldalai Feb 26, 2018
eb7f55a
fix support coverage
gabrielf-eb Feb 26, 2018
5b93f6d
Merge pull request #29 from evbeda/fix-support-coverage
eldalai Feb 26, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
language: python
python:
- "2.7"
script: python test_suite.py
install:
- pip install -r requirements.txt
script: coverage run test_suite.py

after_success:
- coveralls
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Roman-numbers

[![Build Status](https://travis-ci.org/evbeda/Roman-numbers.svg?branch=master)](https://travis-ci.org/evbeda/Roman-numbers)

[![Coverage Status](https://coveralls.io/repos/github/evbeda/Roman-numbers/badge.svg?branch=master)](https://coveralls.io/github/evbeda/Roman-numbers?branch=master)
19 changes: 4 additions & 15 deletions Roman.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,11 @@ def roman(numero):
if not isinstance(numero, int):
return "Only int numbers"


numeros = {
1000 :'M',
900 :'CM',
500 :'D',
400 :'CD',
100 :'C',
90 : 'XC',
50 : 'L',
40 : 'XL',
10: 'X',
9 : 'IX',
5 : 'V',
4 : 'IV',
1 : 'I',
1000: 'M', 900: 'CM', 500: 'D', 400: 'CD', 100: 'C', 90: 'XC', 50: 'L',
40: 'XL', 10: 'X', 9: 'IX', 5: 'V', 4: 'IV', 1: 'I',
}

roman = ''

for key in sorted(numeros.keys(), reverse=True):
Expand All @@ -32,4 +21,4 @@ def roman(numero):
cant = numero // key
roman += value * cant
numero -= cant * key
return roman
return roman
9 changes: 9 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
certifi==2018.1.18
chardet==3.0.4
coverage==4.0.3
idna==2.6
python-coveralls==2.9.1
PyYAML==3.12
requests==2.18.4
six==1.11.0
urllib3==1.22
27 changes: 22 additions & 5 deletions roman_to_decimal.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@

def decimal(roman):
roma = {'M': 1000, 'D': 500, 'C': 100, 'L': 50, 'X': 10, 'V': 5, 'I': 1}
cadena = list(roman)
result = 0
count = 0
a = ['A', 'B', 'E', 'F', 'G', 'H', 'J', 'K', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'W', 'Y', 'Z']
a = [
'A',
'B',
'E',
'F',
'G',
'H',
'J',
'K',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'W',
'Y',
'Z',
]
if any(x in roman for x in a):
result = 'Input is not a roman number'
else:
for letra in cadena:
if len(cadena) != count + 1:
if len(cadena) > 0:
if roma[letra] < roma[cadena[count+1]]:
if roma[letra] < roma[cadena[count + 1]]:
result -= roma[letra]
else:
result += roma[letra]
Expand All @@ -21,5 +40,3 @@ def decimal(roman):
result += roma[letra]
count += 1
return result


5 changes: 4 additions & 1 deletion romandecimalroman.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
from Roman import roman

def roman_to_roman(romano):
return roman(decimal(romano))
return roman(decimal(romano))



12 changes: 6 additions & 6 deletions test_roman.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_roman_decimal_roman_two(self):
def test_roman_decimal_roman_four(self):
resultado = roman(4)
self.assertEqual(resultado, 'IV')

def test_roman_decimal_roman_ten(self):
resultado = roman(10)
self.assertEqual(resultado, 'X')
Expand All @@ -30,22 +30,22 @@ def test_roman_decimal_roman_five(self):

def test_roman_decimal_roman_845(self):
resultado = roman(845)
self.assertEqual(resultado, 'DCCCXLV')
self.assertEqual(resultado, 'DCCCXLV')

def test_roman_decimal_roman_minor(self):
resultado = roman(-1)
self.assertEqual(resultado, "Can't convert to roman number!")

def test_roman_decimal_roman_not_type(self):
resultado = roman(10.5)
self.assertEqual(resultado, "Only int numbers")
self.assertEqual(resultado, "Only int numbers")

def test_romandecimal_one(self):
self.assertEqual(decimal('I'), 1)

def test_romandecimal_two(self):
self.assertEqual(decimal('II'), 2)

def test_romandecimal_three(self):
self.assertEqual(decimal('III'), 3)

Expand All @@ -70,10 +70,10 @@ def test_roman_decimal_3999(self):

def test_roman_decimal_4000(self):
resultado = roman(4000)
self.assertEqual(resultado, 'Not a valid number')
self.assertEqual(resultado, 'Not a valid number')

## definir primer test

class Roman_to_decimal_to_roman(unittest.TestCase):
def test_I(self):
self.assertEqual(roman_to_roman('I'),'I')
Expand Down
9 changes: 6 additions & 3 deletions test_roman_to_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_romandecimal_one(self):

def test_romandecimal_two(self):
self.assertEqual(decimal('II'), 2)

def test_romandecimal_three(self):
self.assertEqual(decimal('III'), 3)

Expand All @@ -29,10 +29,13 @@ def test_romandecimal_3999(self):
self.assertEqual(decimal('MMMCMXCIX'), 3999)

def test_wrong_letter(self):
self.assertEqual(decimal('CCXASDASHDUASBD'), 'Input is not a roman number')
self.assertEqual(
decimal('CCXASDASHDUASBD'),
'Input is not a roman number'
)

## definir primer test

class Roman_to_decimal_to_roman(unittest.TestCase):
def test_all(self):
for number in xrange(1, 4):
Expand Down
4 changes: 3 additions & 1 deletion test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
)
from test_roman import TestRoman


def suite():
"""
Gather all the tests from this module in a test suite.
Expand All @@ -15,6 +16,7 @@ def suite():
test_suite.addTest(unittest.makeSuite(TestRoman))
return test_suite


if __name__ == "__main__":
#So you can run tests from this module individually.
unittest.main()
unittest.main()