<?xml version="1.0" encoding="windows-1252"?>
<node id="716680" title="Re^3: Numerically generate the perl sequence 1, 11, 111, ...." created="2008-10-12 10:48:56" updated="2008-10-12 10:48:56">
<type id="11">
note</type>
<author id="616540">
moritz</author>
<data>
<field name="doctext">
It shouldn't be too hard to make this work.

&lt;p&gt;By simply looking at the sequence of the pair-wise difference and ratio and correlating them to the original sequence or a constant, you can get good guesses for most commonly used sequences, if you just allow a few levels of recursion:


&lt;code&gt;
1, 2, 3, 4, 5
   differences 1, 1, 1, 1 # constant
1, 2, 4, 8, 16
   ratios:     2, 2, 2, 2 # constant
1, 2, 3, 5, 8
   differences: 1, 2, 3, 5 # sames as original  shifted by one
1, 11, 111, 1111, 11111
   differences: 10, 100, 1000, 10000
       ratios: 10, 10, 10 # constant
&lt;/code&gt;

&lt;p&gt;The fibonacci sequence is the only one example that needs autocorrelating. Other ones that could use the autocorrelation are &lt;c&gt;-1, 1, -1, 1, ...&lt;/c&gt; and &lt;c&gt;0, 1, 0, 1, ...&lt;/c&gt;. 

&lt;p&gt;In case of ambiguousness the solution with the shallowest recursion would win. 

&lt;p&gt;I'll try to come up with a prototype implementation that can be used as basis for a specification. But it won't be this or the next week, so have a little patience ;)

&lt;p&gt;Ideally there would be some sub or method that can be overridden to detect sequences if the built-in mechanism fails..
</field>
<field name="root_node">
716367</field>
<field name="parent_node">
716679</field>
</data>
</node>
