[Fwd: Re: [Tutor] how to write an algorithm for sequence]

reavey reavey@nep.net
Tue Feb 11 22:36:15 2003


--------------000805030907060407000008
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit



-------- Original Message --------
Subject: Re: [Tutor] how to write an algorithm for sequence
Date: Wed, 12 Feb 2003 22:28:08 -0500
From: reavey <reavey@nep.net>
To: Danny Yoo <dyoo@hkn.eecs.berkeley.edu>
References: 
<Pine.LNX.4.44.0302111904390.28496-100000@hkn.eecs.berkeley.edu>



Yes. I wrote this as a power of two sequence. I can see how to get the 
next number, however
the algorithm is baffling.
Thanks
re-v

Danny Yoo wrote:

>On Wed, 12 Feb 2003, reavey wrote:
>
>  
>
>>I'm stumped. I made up this sequence and I can't figure out a method.
>>the sequence is 1,5,7,15,19,35, 43, 75...
>>    
>>
>
>Hi Reavey,
>
>
>This isn't quite Python either, but I'll give it a shot.  *grin*
>
>Hmmm... I don't see anything immediate from the sequence above either.
>
>
>But have you tried the method of differences?  Here's how it works: take
>each pair of numbers, subtract them, and see if a pattern emerges.
>
>###
>  
>
>>>>def differences(seq):
>>>>        
>>>>
>...     for i in range(0, len(seq)-1):
>...         print seq[i+1] - seq[i],
>...
>  
>
>>>>differences([1, 5, 7, 15, 19, 35, 43, 75])
>>>>        
>>>>
>4 2 8 4 16 8 32
>###
>
>
>Let's arrange it so that it's easier to see what's going on:
>
>
>    1   5   7   15   19   35   43   75
>      4   2   8    4   16    8    32
>
>
>
>Interesting.  All of the individual "differences" are even, first of all.
>Wait: Reavey, I do see some sort of pattern here.  Do you see it too now?
>
>
>
>Good luck to you!
>
>
>  
>


--------------000805030907060407000008
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title></title>
</head>
<body>
 <br>
<br>
-------- Original Message --------
<table cellpadding="0" cellspacing="0" border="0">
  <tbody>
    <tr>
      <th valign="baseline" align="right" nowrap="nowrap">Subject: </th>
      <td>Re: [Tutor] how to write an algorithm for sequence</td>
    </tr>
    <tr>
      <th valign="baseline" align="right" nowrap="nowrap">Date: </th>
      <td>Wed, 12 Feb 2003 22:28:08 -0500</td>
    </tr>
    <tr>
      <th valign="baseline" align="right" nowrap="nowrap">From: </th>
      <td>reavey <a class="moz-txt-link-rfc2396E" href="mailto:reavey@nep.net">&lt;reavey@nep.net&gt;</a></td>
    </tr>
    <tr>
      <th valign="baseline" align="right" nowrap="nowrap">To: </th>
      <td>Danny Yoo <a class="moz-txt-link-rfc2396E" href="mailto:dyoo@hkn.eecs.berkeley.edu">&lt;dyoo@hkn.eecs.berkeley.edu&gt;</a></td>
    </tr>
    <tr>
      <th valign="baseline" align="right" nowrap="nowrap">References: </th>
      <td><a class="moz-txt-link-rfc2396E" href="mailto:Pine.LNX.4.44.0302111904390.28496-100000@hkn.eecs.berkeley.edu">&lt;Pine.LNX.4.44.0302111904390.28496-100000@hkn.eecs.berkeley.edu&gt;</a></td>
    </tr>
  </tbody>
</table>
 <br>
<br>
<title></title>
      Yes. I wrote this as a power of two sequence. I can see how to get
the next number, however<br>
 the algorithm is baffling.<br>
 Thanks<br>
 re-v<br>
 <br>
 Danny Yoo wrote:<br>
 
<blockquote type="cite"
 cite="midPine.LNX.4.44.0302111904390.28496-100000@hkn.eecs.berkeley.edu"> 
  
  <pre wrap="">On Wed, 12 Feb 2003, reavey wrote:

  </pre>
   
  <blockquote type="cite">     
    <pre wrap="">I'm stumped. I made up this sequence and I can't figure out a method.
the sequence is 1,5,7,15,19,35, 43, 75...
    </pre>
   </blockquote>
   
  <pre wrap=""><!---->
Hi Reavey,


This isn't quite Python either, but I'll give it a shot.  *grin*

Hmmm... I don't see anything immediate from the sequence above either.


But have you tried the method of differences?  Here's how it works: take
each pair of numbers, subtract them, and see if a pattern emerges.

###
  </pre>
   
  <blockquote type="cite">     
    <blockquote type="cite">       
      <blockquote type="cite">         
        <pre wrap="">def differences(seq):
        </pre>
       </blockquote>
     </blockquote>
   </blockquote>
   
  <pre wrap=""><!---->...     for i in range(0, len(seq)-1):
...         print seq[i+1] - seq[i],
...
  </pre>
   
  <blockquote type="cite">     
    <blockquote type="cite">       
      <blockquote type="cite">         
        <pre wrap="">differences([1, 5, 7, 15, 19, 35, 43, 75])
        </pre>
       </blockquote>
     </blockquote>
   </blockquote>
   
  <pre wrap=""><!---->4 2 8 4 16 8 32
###


Let's arrange it so that it's easier to see what's going on:


    1   5   7   15   19   35   43   75
      4   2   8    4   16    8    32



Interesting.  All of the individual "differences" are even, first of all.
Wait: Reavey, I do see some sort of pattern here.  Do you see it too now?



Good luck to you!


  </pre>
 </blockquote>
 <br>
 
</body>
</html>

--------------000805030907060407000008--