16
1
Your task is to decompose a number using the format below.
This is similar to base conversion, except that instead of listing the digits in the base, you list the values, such that the list adds up to the input.
If the given base is n, then each number in the list must be in the form of k*(n**m), where 0<=k<n and m is unique throughout the list.
Specs
- Any reasonable input/output format. Your program/function takes 2 inputs and outputs a list.
- Output list can be in any order.
0can be excluded or included.- Leading
0are allowed. - Built-ins are allowed.
Testcases
number base converted list
input1 input2 output
123456 10 [100000,20000,3000,400,50,6] or [6,50,400,3000,20000,100000]
11 2 [8,2,1] or [0,0,0,0,8,0,2,1]
727 20 [400,320,7]
101 10 [100,1] or [100,0,1]
Scoring
This is code-golf. Shortest solution in bytes wins.
Ah, reversed range... – Leaky Nun – 2016-05-02T04:05:30.213
It is so impressive what can be achieved with so few characters – t-clausen.dk – 2016-05-03T08:24:19.490