Bob, 

Everybody finds these recursive algorithms hard, really hard, especially the 
Tower of Hanoi. Trouble is you can't start at the top.

Start recursion with the factorial function. The factorial of 9 is 9 * 
factorial(8) and so on. Therefore:

function Factorial n
     if n = 1 then
      return 1
       else
        return n * factorial(n-1)
     end if 
end factorial

And everybody finds fitting algorithms to physics problems hard. Again, you 
can't start at the top.  Trust me, I spent my  life teach students how to put 
the math into physics.

Part of the problem of programming for physics problems is the computer 
language. 

For example, the algorithm to draw the path of a baseball is as simple as: 

  put 4 into  vx --x component of the velocity of the turtle
  put 5 into vy
  put .1 into gravity
  repeat until ycor() < 0
    incXY vx,vy --increase the x coordinate by vx and the y coordinate by vy
    subtract gravity from vy -- add the acceleration (the rate of change in the 
velocity) to vy
  end repeat

This in Turtle Graphics. This is why I have been promoting TG for science 
students. It is geometrically oriented. The turtle is easier to talk to, and he 
is really good at solving differential equations--as in the problem of the 
baseball above..

More of this in:

go url "http://jamesphurley.com/RunRev/TurtleGraphics.livecode";

Me? I find programming for the internet hard, really hard. I started in the 
middle. Big mistake.

Jim

> 
> Message: 25
> Date: Thu, 19 Jul 2012 16:37:03 -0700
> From: Bob Sneidar <b...@twft.com>
> To: How to use LiveCode <use-livecode@lists.runrev.com>
> Subject: Re: Hanoi Tower programming challenge...
> Message-ID: <ee614a6a-5abf-4af7-ae22-ce88ccd9b...@twft.com>
> Content-Type: text/plain; charset=us-ascii
> 
> I just read up on this. Honestly, if someone had asked me to come up with a 
> programmatical solution to this physical problem, I could not do it to save 
> my life. I don't know why. I consider myself to be fairly intelligent, but I 
> cannot turn physical problems like this into a formula. 
> 
> I stumbled at this on a lot of tests in school. Whenever it got to these 
> kinds of problems I would stop dead in my tracks, even when the teacher said 
> to skip over the problems we could not solve. I tried to work out the 
> relationships of the physical problem to the mathemetical expression of it 
> and I could not go on until I "saw" in my head how it all worked and why. 
> 
> I could probably get through the physical puzzle fine and "see" why it had to 
> work that way, but to convert it to a formula is quite beyond me. <sigh> Very 
> frustrating. This is probably why I could never be a very good developer, at 
> least when it comes to this sort of thing. 
> 
> Bob
> 
> 


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to