Skip to content
Merged
Changes from all commits
Commits
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
16 changes: 9 additions & 7 deletions all-your-base/all_your_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@

def rebase(input_base: int, digits: list[int], output_base: int):
"""
Convert a non-negative integer represented as digits in one base to digits in another base.
Convert a non-negative integer represented as digits in one base
to digits in another base.

:param int input_base: Base of the input digits; must be >= 2.
:param list[int] digits: Sequence of digits where each d satisfies 0 <= d < input_base.
Leading zeros are allowed; an empty list denotes 0.
:param list[int] digits: Sequence of digits where each d satisfies
0 <= d < input_base. Leading zeros are allowed;
an empty list denotes 0.
:param int output_base: Base for the output digits; must be >= 2.
:returns: Digits of the same number in ``output_base``, without leading zeros
(except ``[0]`` for zero).
:returns: Digits of the same number in ``output_base``, without leading
zeros (except ``[0]`` for zero).
:rtype: list[int]
:raises ValueError: If ``input_base < 2``, if any digit violates ``0 <= d < input_base``,
or if ``output_base < 2``.
:raises ValueError: If ``input_base < 2``, if any digit violates
``0 <= d < input_base``, or if ``output_base < 2``.
"""

# for input.
Expand Down
Loading