19
We have a strictly increasing sequence of non-negative integers, like:
12 11 10
Wait! This sequence isn't strictly increasing, is it? Well, the numbers are written in different bases. The least possible base is 2, the biggest is 10.
The task is to guess bases each number is written, so that:
- the sequence is strictly increasing,
- the sum of the bases is maximised.
For instance, the solution for the sample will be:
6 8 10
because under those bases the sequence becomes 8 9 10
decimal - a strictly increasing sequence, and we are not capable of finding bases for which the sequence remains strictly increasing and whose sum is bigger than 6+8+10
.
Due to the second limitation a solution 3 5 7
is not satisfactory: in spite of fact that the sequence becomes 5 6 7
under those bases - we need to maximise the bases sum, and 3+5+7 < 6+8+10
.
If under no bases 2<=b<=10
is it possible for the series to be strictly increasing, for instance:
102 10000 10
single
0
should be output.
The input sequence can be passed in the way it's most convenient for your solution (standard input / command line parameters / function arguments...).
1Is
1 3 5
a rising sequence? What about1 7 22
? (in base 10) – Doorknob – 2015-08-07T20:35:00.833Yes,
1 3 5
and1 7 22
are both rising under base 10. So, the solution for both cases is10 10 10
, because we need to maximize the sum of bases while assuring that the sequence is rising when n-th number is interpreted as being written in base equal to n-th term of solution. – pawel.boczarski – 2015-08-07T20:43:03.550Okay, so a rising sequence does not necessarily have to consist of consecutive numbers. – Doorknob – 2015-08-07T20:47:52.850
By rising, do you mean strictly increasing, i.e., that
1 1 1
is not a rising sequence? – Dennis – 2015-08-07T20:49:47.9472@Dennis Yes, I mean strictly increasing sequence.
1 1 1
or3 3 4
are not rising. – pawel.boczarski – 2015-08-07T20:53:29.273Are the inputs always 3 numbers, or are you just missing examples of other lengths? – Geobits – 2015-08-07T21:09:51.037
@Geobits Inputs of any length are accepted. Just a simple example: for
11 10 10 10
the solution is6 8 9 10
, and for10 10 10 10 10
-6 7 8 9 10
. – pawel.boczarski – 2015-08-07T21:15:15.903Cool, I just wanted to make sure I wasn't missing something where you said it would always be length 3. – Geobits – 2015-08-07T21:16:03.610
Proposed test case:
19 18 17
. My answer was failing that one. – Dennis – 2015-08-08T01:36:09.0633If comments indicate that the question is open to misinterpretation, don't just reply in comments. Edit the question so that other people don't waste time writing answers which interpret it differently to you. – Peter Taylor – 2015-08-08T07:04:59.730
3And on the subject of ambiguities, one of the comments on my answer claims that we should assume that the numbers are written in canonical form in the given base. If this is so, please correct the phrase "The least possible base is 2" to something like "The least possible base is one greater than the largest digit value". – Peter Taylor – 2015-08-08T07:17:09.433