Hate to say this but you are a bit late.  I had my students at University
and here at Compuware create three to four different versions of the Tower's
of Hanoi solution in PL/SQL.  Used PL/SQL tables, stack processing,
recursion (yes it can be done), and others.  I also had (yep had - lost
this) one for both PL/I and TSO/CLIST Dialog Manager & VMS DCL.  I actually
created screens where you could dynamically choose the number of pegs and
pieces.  It also verified that you were putting smaller pieces on top of
larger ones (one of the core rules for Tof H).  

Isn't programming great?

Thank You

Stephen P. Karniotis
Technical Alliance Manager
Compuware Corporation
Direct: (313) 227-4350
Mobile: (248) 408-2918
Email:  [EMAIL PROTECTED] 
Web:    www.compuware.com 

 -----Original Message-----
Bobak, Mark
Sent:   Monday, December 08, 2003 4:19 PM
To:     Multiple recipients of list ORACLE-L
Subject:        A brief detour....;-)

So, I saw on SlashDot (http://www.slashdot.org/) a story about a guy who has
over 100 different implementations of the Towers of Hanoi solution, each in
a different language.  Since he didn't have one in PL/SQL, I decided to
write one.  

Here it is:
create or replace package hanoi
is
from_peg  constant number := 1;
to_peg    constant number := 3;
using_peg constant number := 2;

procedure play(n number);

end hanoi;
/
create or replace package body hanoi
is

procedure do_hanoi(n number, from_peg number, to_peg number, using_peg
number)
is
begin
    if(n > 0) then
        do_hanoi(n-1,from_peg, using_peg, to_peg);
        dbms_output.put_line('move '||from_peg||' --> '||to_peg);
        do_hanoi(n-1, using_peg, to_peg, from_peg);
    end if;
end;
procedure play(n number)
is
begin
    do_hanoi(n, from_peg, to_peg, using_peg);
end;
end;
/

This concludes this public service announcement.  We now return you to our
regularly scheduled programming.

-Mark

PS  Yes, it's a slow day....;-)
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Bobak, Mark
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it. 

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Karniotis, Stephen
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to