15
1
EDIT: I will be accepting an answer Monday, 2/15/2016. May the bytes be ever in your favor!
In his "Print the N-Bonacci Sequence" challenge, @DJMcGoathem describes the N-bonacci sequences, wherein the previous N numbers are summed, instead of the traditional 2 of the Fibonacci sequence (said to be the "duonacci sequence"). He then asked to take two inputs, X and N, then output the Xth N-nacci number.
I propose the opposite.
Given a sequence, output which N-nacci sequence it is a subset of. I say "subset of" because:
- A) these sequences are infinite
- B) if given the start of the sequence, you could just count the number of leading 1s
In the case that it could belong to multiple N-nacci sequences, chose the lowest one.
In the case that it does not belong to any N-nacci sequence, then your program may do anything other than print something that could be mistaken for output. These behaviors include (but are not limited to): infinite loop, error, crash, delete itself (*cough cough* vigil *cough cough*), or create a black hole (as long as this black hole does not produce anything that could be mistaken for valid output).
For the sake of this challenge, these sequences start with 1. This means any N-nacci sequence starts with N ones. Furthermore, N must be a positive integer. So no -1-nacci, etc.
Test cases:
1,1,1 -> 1
49, 97 -> 7
55, 89, 144 -> 2
1 -> 1
6765 -> 2
12, 23, 45, 89 -> 12
100, 199 -> 100
1
create a black hole (as long as this black hole does not produce anything that could be mistaken for valid output).
My, the spirals of the black hole are converging to the golden ratio! It must be valid output for a duoacci sequence! – Conor O'Brien – 2016-01-31T20:26:44.9301
@CᴏɴᴏʀO'Bʀɪᴇɴ It may be a beautiful golden ratio, but Do NOT go near the black hole! https://www.youtube.com/watch?v=TTUQyEr-sg0
– Level River St – 2016-01-31T20:41:21.2671Oh my, this is much harder than I originally thought... – GamrCorps – 2016-02-01T02:16:56.397
@mbomb007 what's the difference between positive integers and natural numbers? – Not that Charles – 2016-02-03T21:25:56.423
@NotthatCharles Positive integers is a clearer way to say it if you're excluding zero, because natural numbers includes zero. – mbomb007 – 2016-02-03T21:51:36.040
1@mbomb007 ah. I thought 1 was the first natural number. I must have been thinking of counting numbers – Not that Charles – 2016-02-03T22:26:42.583
@NotthatCharles It's actually somewhat ambiguous, but I include zero. See wikipedia.
– mbomb007 – 2016-02-03T22:33:01.660