Skip to content

Commit 8b4f4cd

Browse files
committed
Updated return type to Iterator[int]
1 parent b19c7d3 commit 8b4f4cd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

data_structures/stacks/lexicographical_numbers.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
from collections.abc import Iterator
22

33

4-
def lexical_order(max_number: int) -> Iterator[str]:
4+
def lexical_order(max_number: int) -> Iterator[int]:
55
"""
66
Generate numbers in lexical order from 1 to max_number.
77
8-
>>> " ".join(lexical_order(13))
8+
>>> " ".join(map(str, lexical_order(13)))
99
'1 10 11 12 13 2 3 4 5 6 7 8 9'
1010
>>> list(lexical_order(1))
11-
['1']
12-
>>> " ".join(lexical_order(20))
11+
[1]
12+
>>> " ".join(map(str, lexical_order(20)))
1313
'1 10 11 12 13 14 15 16 17 18 19 2 20 3 4 5 6 7 8 9'
14-
>>> " ".join(lexical_order(25))
14+
>>> " ".join(map(str, lexical_order(25)))
1515
'1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 23 24 25 3 4 5 6 7 8 9'
1616
>>> list(lexical_order(12))
17-
['1', '10', '11', '12', '2', '3', '4', '5', '6', '7', '8', '9']
17+
[1, 10, 11, 12, 2, 3, 4, 5, 6, 7, 8, 9]
1818
"""
1919

2020
stack = [1]
@@ -24,7 +24,7 @@ def lexical_order(max_number: int) -> Iterator[str]:
2424
if num > max_number:
2525
continue
2626

27-
yield (str(num))
27+
yield (num)
2828
if (num % 10) != 9:
2929
stack.append(num + 1)
3030

0 commit comments

Comments
 (0)