17
2
Consider a sequence based on recurrence relations, f(n) = f(n-1)+f(n-2)
, starting with f(1) = x1, f(2) = x2
. For x1 = 2, x2 = 1
, the sequence begins like this:
2 1 3 4 7 11 18 29 47 76 123 199 322 521 843
Concatenating this into a string will give:
213471118294776123199322521843
Now, divide this list into the smallest possible numbers that gives y(n) > y(n-1)
. Start with the first number, then the second etc. The first output number should always be a single digit. Pad the last number with the required number of zeros.
2 13 47 111 829 4776 12319 93225 218430
You will get two numbers, (x1, x2)
as input, on any convenient format, and the challenge is to output the sorted list.
Rules:
- Function and programs are OK
- The initial sequence shall have exactly 15 numbers (The last number is
f(15)
). x1
andx2
are non-negative (zero is possible).- The output can be on any convenient format
- The output vector
y
must be created so thaty2 > y1
.- First the smallest possible
y1
, then the smallest possibley2
, theny3
and so on.
- First the smallest possible
- If
x1 = x2 = 0
then output 15 zeros (on the same format as other output, i.e. not000000000000000
).
Examples:
Input: 1 1
Output: 1 12 35 81 321 345 589 1442 3337 7610
Input: 3 2
Output: 3 25 71 219 315 0811 3121 23435 55898 145300
|
Optional leading zero
Input: 0 0
Output: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The shortest code in bytes wins. Please include a link to an online interpreter if possible.
What exactly do you mean by "smallest possible numbers"? Smallest average? Smallest maximum? Something else? – isaacg – 2016-01-05T11:11:05.340
@isaacg So as the nth number is greater than (n-1)th. – nicael – 2016-01-05T11:14:15.080
The smallest individual numbers. I.e. you can't take the trivial solution with only two numbers:
(2, 13471118294776123199322521843)
. I'll explain it better. – Stewie Griffin – 2016-01-05T11:14:18.4731To clarify my question, what would the proper division of
5467
be?54 67
?5 46 70
? – isaacg – 2016-01-05T11:20:48.4771Related but slightly different – Sp3000 – 2016-01-05T11:21:25.747
@Sp3000, I haven't seen that one. Yes, that's definitely related. – Stewie Griffin – 2016-01-05T11:22:29.350
@isaacg, if those are the only numbers in the sequence:
5 46 70
. – Stewie Griffin – 2016-01-05T11:23:20.227How are those the smallest numbers? 67<70. The other question asked for the most separate output numbers, for comparison. – isaacg – 2016-01-05T11:25:24.897
@isaacg, I've clarified it a bit in the challenge. Find the smallest possible
y1
, then the smallest possibley2
, then the smallesty3
that makesy1 < y2 < y3
. Does it make sense or is it still unclear? – Stewie Griffin – 2016-01-05T11:27:54.280@nicael, you're right. Fixed! – Stewie Griffin – 2016-01-05T12:15:54.497
Is it fine if my function produces more numbers than shown in your example? – nicael – 2016-01-05T12:22:15.933
So the only case when y1 <= y2 <= y3 is when x1 == x2 == 0? – edc65 – 2016-01-05T12:28:00.367
@edc65, yes it is. – Stewie Griffin – 2016-01-05T12:33:34.053
3The 0 thing seems like a rather annoying and unnecessary exception. – Martin Ender – 2016-01-05T16:07:39.333
@StewieGriffin That's much better, thank you. – isaacg – 2016-01-05T23:21:16.200