When in the Fibonacci number recurrence fn+2=fn+fn+1 one replaces the "+" with string concatenation one will get the sequence of Fibonacci words. If we start with F0=a and F1=b, then the first few elements will be a,b,ab,bab,abbab,bababbab,abbabbababbab,... etc.
If N>1 and n<N then Fn will naturally occur as a substring in FN:
For example, if n=3 and N=6, Then F4, by construction, contains a copy of F3 at its end. F5, being the concatenation of F3 and F4, therefore contains two copies, and F6 three copies, one from F4 and two from F5.
We can find these copies at offsets 2,5 and 10:
a
b
ab
bab
-->
abbab
-->
bababbab
--> -->
abbabbababbab
-->--> -->
But, we cannot rule out more occurrences, for example, there is one at offset 7 that is not directly explained by the recursion formula:
abbabbababbab
***
We'll call such occurrences "strange" as opposed to the "regular" occurrences above.
Task:
Given N>n and offset o your program or function must return one out of three consistent values indicating whether Fn occurs in FN at offset o and if so which kind of occurrence it is.
Test cases:
N n o answer
------------------------------------------
4 0 0 regular
4 0 1 wrong
4 0 2 wrong
4 0 3 regular
4 0 4 wrong
5 0 0 wrong
5 0 1 regular
5 0 2 wrong
5 0 3 regular
5 0 4 wrong
5 0 5 wrong
5 0 6 regular
5 0 7 wrong
4 1 0 wrong
4 1 1 regular
4 1 2 regular
4 1 3 wrong
4 1 4 regular
5 1 0 regular
5 1 1 wrong
5 1 2 regular
5 1 3 wrong
5 1 4 regular
5 1 5 regular
5 1 6 wrong
5 1 7 regular
1 0 0 wrong
10 2 7 wrong
7 3 0 regular
7 3 7 strange
7 3 9 wrong
7 3 10 regular
7 3 11 wrong
14 7 47 strange
14 7 479 strange
14 7 335 strange
14 7 335 strange
14 7 369 strange
14 7 513 strange
14 7 100 wrong
14 7 200 wrong
14 7 300 wrong
14 7 13 regular
14 7 123 regular
14 7 233 regular
14 7 322 regular
If you need even more test cases here is the Python script that generated the above.
Inspired by this puzzling SE post:
https://puzzling.stackexchange.com/q/122866/71595
¹„abD²èu©²ǝSλè«N²Qiu©]³.$Du‚®δÅ?). Can probably be golfed a bit to 6-7, but that would still tie it with my current approach, so I'll just leave it as is. \$\endgroup\$IFin 05AB1E... \$\endgroup\$