Login and get codingRecursion in computer science is a method of solving a problem where the solution depends on solutions to smaller instances of the same problem (Wikipedia).

It's one of the most powerful programming techniques that has many interesting use cases. If implement it correctly, oftentimes it can offer insights to the seemingly complicated problems. Some famous examples are Tower of Hanoi and factorial numbers.

Recursion has two distinct components:

- The base case returns a value without making any subsequent calls, and
- the reduction step which reduces the size of problem to a small one in each step.
In this bite you will take the challenge to solve a number conversion problem: given a positive number, and target base b, convert this number to that base.

To make it a bit simpler, the base is guaranteed to be in one of these: 2, 6, or 8:

# Example: we can ignore the prefix part of each base: such as '0b' for base 2, '0o' # for base 8, etc. Just return the converted number. >>> dec_to_base(10, 2) -> 1010 - as of "0b1010" >>> dec_to_base(24, 6) -> 40 >>> dec_to_base(256, 8) -> 400 - as of "0o400"

Metrics »

70 out of 72 users completed this Bite.

Will you be Pythonista #71 to crack this Bite?

Resolution time: ~36 min. (avg. submissions of 5-240 min.)

Pythonistas rate this Bite 4.33 on a 1-10 difficulty scale.

» Up for a challenge? 💪