Skip to content

Commit 155aa91

Browse files
committed
improve "see for details" lines & fix spacing
1 parent f60ba7e commit 155aa91

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎exercises/practice/roman-numerals/.approaches/introduction.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def roman(number: int) -> str:
5151
return res
5252
```
5353

54-
See [`if-else`][if-else] for details.
54+
See the [`if-else`][if-else] approach for details.
5555

5656
### With table lookup
5757

@@ -68,7 +68,7 @@ def roman(number):
6868
digits = [int(d) for d in str(number)]
6969

7070
# get the row in the lookup table for the most-significant decimal digit
71-
inverter = len(digits) - 1
71+
inverter = len(digits) - 1
7272

7373
# translate decimal digits list to Roman numerals list
7474
roman_digits = [table[inverter - i][d - 1] for i, d in enumerate(digits) if d != 0]
@@ -77,7 +77,7 @@ def roman(number):
7777
return ''.join(roman_digits)
7878
```
7979

80-
See [`table-lookup`][table-lookup] for details.
80+
See the [`table-lookup`][table-lookup] approach for details.
8181

8282

8383
## Loop over Romans approaches
@@ -101,15 +101,15 @@ def roman(number: int) -> str:
101101
result = ''
102102
while number:
103103
for arabic in ROMAN.keys():
104-
if number >= arabic:
104+
if number >= arabic:
105105
result += ROMAN[arabic]
106106
number -= arabic
107107
break
108108
return result
109109
```
110110

111111
There are a number of variants.
112-
See [`loop-over-romans`][loop-over-romans] for details.
112+
See the [`loop-over-romans`][loop-over-romans] approach for details.
113113

114114
## Other approaches
115115

@@ -163,7 +163,7 @@ def roman_recur(num: int, idx: int, digits: list[str]):
163163
return roman_recur(num, idx + 1, digits)
164164
```
165165

166-
See [`recurse-match`][recurse-match] for details.
166+
See the [`recurse-match`][recurse-match] approach for details.
167167

168168

169169
### Over-use a functional approach

‎exercises/practice/roman-numerals/.approaches/itertools-starmap/content.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from itertools import starmap
55

66
def roman(number: int) -> str:
7-
orders = [(1000, 'M '), (100, 'CDM'), (10, 'XLC'), (1, 'IVX')]
7+
orders = [(1000, 'M '), (100, 'CDM'), (10, 'XLC'), (1, 'IVX')]
88
options = lambda I, V, X: ['', I, I * 2, I * 3, I + V, V, V + I, V + I * 2, V + I * 3, I + X]
99
compute = lambda n, chars: options(*chars)[number % (n * 10) // n]
1010
return ''.join(starmap(compute, orders))

‎exercises/practice/roman-numerals/.approaches/loop-over-romans/content.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def roman(number: int) -> str:
99
result = ''
1010
while number:
1111
for arabic in ROMAN.keys():
12-
if number >= arabic:
12+
if number >= arabic:
1313
result += ROMAN[arabic]
1414
number -= arabic
1515
break
@@ -38,7 +38,7 @@ def roman(number: int) -> str:
3838
Using a pair of lists is also possible, with a shared index from `enumerate()`.
3939

4040
```python
41-
# Use a translation
41+
# Use a translation
4242
numbers = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
4343
names = [ 'M', 'CM','D','CD', 'C','XC','L','XL', 'X','IX','V','IV', 'I']
4444

‎exercises/practice/roman-numerals/.approaches/table-lookup/content.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def roman(number):
1313
digits = [int(d) for d in str(number)]
1414

1515
# get the row in the lookup table for the most-significant decimal digit
16-
inverter = len(digits) - 1
16+
inverter = len(digits) - 1
1717

1818
# translate decimal digits list to Roman numerals list
1919
roman_digits = [table[inverter - i][d - 1] for i, d in enumerate(digits) if d != 0]

0 commit comments

Comments
 (0)