Skip to content

[All Your Base] Two tests may be expecting wrong values #3855

Closed
@jmodjeska

Description

@jmodjeska

I have some feedback on the tests for this exercise: https://exercism.org/tracks/python/exercises/all-your-base.

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

https://github.com/exercism/python/blob/main/exercises/practice/all-your-base/all_your_base_test.py#L35

    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

https://github.com/exercism/python/blob/main/exercises/practice/all-your-base/all_your_base_test.py#L32

    def test_hexadecimal_to_trinary(self):
        self.assertEqual(rebase(16, [2, 10], 3), [1, 1, 2, 0])
  • 210 in base-16 is 528 in base-10
  • 520 in base-10 is 201120 in base-3

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions