🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by David Kressen Mon, 02 Nov 1992 23:37
LogoWriter Challenge
#11
Author: David Kressen
Date: Mon, 02 Nov 1992 23:37
57 lines
2716 bytes
I was at a meeting the other day where Richard Nupoll of the TEAMS
distance learning project in Mathematics and Science (sponsored by the Los
Angeles County Office of Eduction) turned us loose for a few minutes with
one of the patterning exercises from a math unit.  He distributed ten
numbered cards to each of us, with instructions to order the cards so they
would deal out in order from one to ten, if one card were buried back at
the bottom of the deck between each card which was dealt.  We spent a few
minutes experimenting, after which a few of us were able to produce the
desired sequence:  1 6 2 10 3 7 4 9 5 8.  Rick then suggested followup
possibilities:  a sequence in which two cards were buried between each one
dealt, or a sequence which involved only seven of the cards.
 
The extension of this exercise to include a deck of any size, with any
number of cards buried after each one dealt, seemed to me to have all the
elements for a great middle school Logo programming project: a
clearly-defined task; concrete objects to play with in order to get the
"feel" of the solution; and opportunities to use both top-down and
bottom-up analysis, both global and local variables, and plenty of
experience with list manipulation and recursive control structures.
 
I offer below a LogoWriter solution to the problem, to which I would
appreciate your comments.  Of course, it will spoil things for you if you
look at my solution before working out your own!
 
- - - - - - - - - - - - - - - - - - - - -
 
TO DEAL
cc ct ht
type [How many cards in the deck?]
name first readlistcc "CARDS
type [How many cards get buried after each one is dealt out?]
name first readlistcc "BURY
name XDECK :CARDS [] "DECK
(pr char 13 [Here is the sequence:] SEQUENCE 1 :DECK)
END
 
TO XDECK :CARDS :DECK 
if :CARDS = 0 [op :DECK]
op XDECK :CARDS-1 fput "X :DECK
END
 
TO SEQUENCE :COUNT :DECK
insert :COUNT - 1 tab pr :DECK
if :COUNT - 1 = :CARDS [op RESEQUENCE :DECK]
op SEQUENCE 1 + :COUNT fput :COUNT bf ROTATE :BURY :DECK
END
 
TO RESEQUENCE :DECK
if 1 = first :DECK [op :DECK]
op RESEQUENCE lput first :DECK bf :DECK
END
 
TO ROTATE :BURY :DECK
if "X <> first :DECK [op ROTATE :BURY lput first :DECK bf :DECK]
if :BURY = 0 [op :DECK]
op ROTATE :BURY - 1 lput first :DECK bf :DECK
END
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads