-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python/roman-numerals: 1st iteration - py3.12
- Loading branch information
Showing
15 changed files
with
649 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!coverage.py: This is a private format, don't read it directly!{"arcs":{"/home/vpayno/git_vpayno/exercism-workspace/python/roman-numerals/test/__init__.py":[[0,0],[0,-1]],"/home/vpayno/git_vpayno/exercism-workspace/python/roman-numerals/roman_numerals.py":[[0,1],[1,3],[3,5],[5,6],[6,7],[7,10],[10,-1],[10,11],[11,13],[13,14],[14,15],[15,16],[16,17],[17,18],[18,19],[19,20],[20,21],[21,22],[22,23],[23,24],[24,25],[25,26],[26,28],[28,29],[29,30],[30,31],[31,29],[29,28],[28,33],[33,-10]]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?xml version="1.0" ?> | ||
<coverage branch-rate="1" branches-covered="4" branches-valid="4" complexity="0" line-rate="0.9615" lines-covered="25" lines-valid="26" timestamp="1713022927789" version="4.5.4"> | ||
<!-- Generated by coverage.py: https://coverage.readthedocs.io --> | ||
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd --> | ||
<sources> | ||
<source>/home/vpayno/git_vpayno/exercism-workspace/python/roman-numerals</source> | ||
</sources> | ||
<packages> | ||
<package branch-rate="1" complexity="0" line-rate="0.9615" name="."> | ||
<classes> | ||
<class branch-rate="1" complexity="0" filename="roman_numerals.py" line-rate="0.9615" name="roman_numerals.py"> | ||
<methods/> | ||
<lines> | ||
<line hits="0" number="0"/> | ||
<line hits="1" number="3"/> | ||
<line hits="1" number="5"/> | ||
<line hits="1" number="6"/> | ||
<line hits="1" number="7"/> | ||
<line hits="1" number="10"/> | ||
<line hits="1" number="11"/> | ||
<line hits="1" number="13"/> | ||
<line hits="1" number="14"/> | ||
<line hits="1" number="15"/> | ||
<line hits="1" number="16"/> | ||
<line hits="1" number="17"/> | ||
<line hits="1" number="18"/> | ||
<line hits="1" number="19"/> | ||
<line hits="1" number="20"/> | ||
<line hits="1" number="21"/> | ||
<line hits="1" number="22"/> | ||
<line hits="1" number="23"/> | ||
<line hits="1" number="24"/> | ||
<line hits="1" number="25"/> | ||
<line hits="1" number="26"/> | ||
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="28"/> | ||
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="29"/> | ||
<line hits="1" number="30"/> | ||
<line hits="1" number="31"/> | ||
<line hits="1" number="33"/> | ||
</lines> | ||
</class> | ||
</classes> | ||
</package> | ||
<package branch-rate="1" complexity="0" line-rate="1" name="test"> | ||
<classes> | ||
<class branch-rate="1" complexity="0" filename="test/__init__.py" line-rate="1" name="__init__.py"> | ||
<methods/> | ||
<lines/> | ||
</class> | ||
</classes> | ||
</package> | ||
</packages> | ||
</coverage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[run] | ||
omit = __init__.py, *_test.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../.pylintrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[pytest] | ||
pythonpath = . | ||
addopts = --doctest-modules | ||
markers = | ||
task: exercise task/step |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,33 @@ | ||
def roman(number): | ||
pass | ||
"""Python Roman Numerals Exercism""" | ||
|
||
from collections import OrderedDict | ||
|
||
type modern_numeral_t = int # type: ignore[valid-type] | ||
type roman_numeral_t = str # type: ignore[valid-type] | ||
type map_d2r_t = OrderedDict[modern_numeral_t, roman_numeral_t] # type: ignore[valid-type] | ||
|
||
|
||
def roman(number: modern_numeral_t) -> roman_numeral_t: | ||
rn: roman_numeral_t = "" | ||
|
||
d2r: map_d2r_t = OrderedDict() | ||
d2r[1] = "I" | ||
d2r[4] = "IV" | ||
d2r[5] = "V" | ||
d2r[9] = "IX" | ||
d2r[10] = "X" | ||
d2r[40] = "XL" | ||
d2r[50] = "L" | ||
d2r[90] = "XC" | ||
d2r[100] = "C" | ||
d2r[400] = "CD" | ||
d2r[500] = "D" | ||
d2r[900] = "CM" | ||
d2r[1000] = "M" | ||
|
||
for d, r in reversed(d2r.items()): | ||
while number >= d: | ||
rn = f"{rn}{r}" | ||
number -= d | ||
|
||
return rn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
> """Python Roman Numerals Exercism""" | ||
|
||
> from collections import OrderedDict | ||
|
||
> type modern_numeral_t = int # type: ignore[valid-type] | ||
> type roman_numeral_t = str # type: ignore[valid-type] | ||
> type map_d2r_t = OrderedDict[modern_numeral_t, roman_numeral_t] # type: ignore[valid-type] | ||
|
||
|
||
> def roman(number: modern_numeral_t) -> roman_numeral_t: | ||
> rn: roman_numeral_t = "" | ||
|
||
> d2r: map_d2r_t = OrderedDict() | ||
> d2r[1] = "I" | ||
> d2r[4] = "IV" | ||
> d2r[5] = "V" | ||
> d2r[9] = "IX" | ||
> d2r[10] = "X" | ||
> d2r[40] = "XL" | ||
> d2r[50] = "L" | ||
> d2r[90] = "XC" | ||
> d2r[100] = "C" | ||
> d2r[400] = "CD" | ||
> d2r[500] = "D" | ||
> d2r[900] = "CM" | ||
> d2r[1000] = "M" | ||
|
||
> for d, r in reversed(d2r.items()): | ||
> while number >= d: | ||
> rn = f"{rn}{r}" | ||
> number -= d | ||
|
||
> return rn |
Oops, something went wrong.