I have some feedback on the tests for this exercise: All Your Base in Python on Exercism.
I believe the intent of the exercise is to treat the input list digits
as a single number in the original input_base
and to convert that number to a number in output_base
expressed as a list of digits. For example, rebase(7, [0, 6, 0], 10)
means, “convert 60 from base-7 to base-10.”
If that is a correct understanding, then I believe that two of the tests are expecting incorrect results:
First Issue
def test_15_bit_integer(self):
self.assertEqual(rebase(97, [3, 46, 60], 73), [6, 10, 45])
- 34660 in base-97 is 269295571 in base-10
- 269295571 in base-10 is 935177131 in base-73
The correct answer should be [9, 35, 17, 71, 31]
Second Issue
def test_hexadecimal_to_trinary(self):
self.assertEqual(rebase(16, [2, 10], 3), [1, 1, 2, 0])
The correct answer should be [2, 0, 1, 1, 2, 0]
Thanks for your time and my apologies if I’m missing something about the exercise or the math involved here.
My code for this challenge, which you’re under no obligation to look at unless it’s diagnostically useful for you, is here.