Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #9425

Re: Valentine Bingo - Comments?

From Steve Graham <jsgrahamus@yahoo.com>
Newsgroups comp.lang.forth
Subject Re: Valentine Bingo - Comments?
Date 2012-02-07 07:39 -0700
Organization Aioe.org NNTP Server
Message-ID <jgrd3o$evp$1@speranza.aioe.org> (permalink)
References <jfsgbb$lu6$1@speranza.aioe.org>

Show all headers | View raw


Hugh/Paul:

Thank you for your interest and comments.  Always there is more than 1 
way to code a solution to problems, including this one.  Below is my 
final solution.  I ended up using some of Stephen Pelc's code, because 
it was better/shorter/more succinct than my own.  Also, I made the final 
output such that there were 2 cards per page.  Earlier I had been 
outputting this from Chrome, but with this final change I used Firefox 
instead.  Finally I included a heart for the free square in the middle: 
  It was for Valentine's Day.


Steve

---

\
\ Valentine Bingo
\

create wordarr
     ," Be Mine"
     ," Love"
     ," It's Love"
     ," All Mine"
     ," Kiss Me"
     ," You & Me"
     ," Awesome"
     ," My Baby"
     ," Love Me"
     ," All Star"
     ," My Way"
     ," Love You"
     ," For You"
     ," Cool"
     ," I Hope"
     ," Love Life"
     ," Angel"
     ," Sweet Talk"
     ," True Love"
     ," Be Good"
     ," How Nice"
     ," Let's Kiss"
     ," #1 Fan"
     ," Be True"
     ," Love Her"
     0 ,

\ number of phrases
25 constant #wordarr

\ which numbers chosen
create chosen-bingo-numbers #wordarr allot

\ chosen numbers in order
create ordered-bingo-numbers #wordarr allot

\ jump from one phrase to the next
: jumper	        \ addr -- addr'
   count + aligned
;

\ get nth phrase
: nth$		\ n base -- addr
   swap 0 ?do  jumper  loop
;

\ print phrases
: .tab		\ base --
   begin
     dup @
    while
     dup count cr type  jumper
   repeat
   drop
;

\ print first part of webpage
: .top-html          \ --
     cr
     cr ." <HTML>"
     cr ."   <BODY>"
     cr ."     <TABLE>"
;

\ print last part of webpage
: .bottom-html          \ --
     cr ."     </TABLE>"
     cr ."     <BR>"
     cr ."   </BODY>"
     cr ."  </HTML>"
     cr
  ;

\ get 24 random non-repeating numbers in order
: get-bingo-numbers  \ --
     #wordarr chosen-bingo-numbers over erase
     ordered-bingo-numbers over erase
     24 0 do
        dup choose
        begin
          dup chosen-bingo-numbers + c@ 0 >
         while
            drop dup choose
        repeat
        chosen-bingo-numbers over + 1 swap c!
        ordered-bingo-numbers i + c!
     loop
     drop
;

\ print nth square's phrase given proper number
: (.square)         \ n --
     ordered-bingo-numbers + c@
     wordarr nth$ count type
;

\ print nth square's phrase given any number
: .square           \ n --
     dup 12 <
     if
       (.square)
     else
       dup 12 =
       if
         drop ." <img src='heart.png' alt='Heart' height='70' width='70'/>"
       else 1- (.square)
       then
     then
;

\ print card
: .card              \ --
     get-bingo-numbers
     cr ."           <TABLE border=1 height=673 width=446>"
     cr ."             <TR height='20%' style='color:red;'>"
     cr ."               <TH style='font-size:200%' width='20%'>B</TH>"
     cr ."               <TH style='font-size:200%' width='20%'>I</TH>"
     cr ."               <TH style='font-size:200%' width='20%'>N</TH>"
     cr ."               <TH style='font-size:200%' width='20%'>G</TH>"
     cr ."               <TH style='font-size:200%' width='20%'>O</TH>"
     cr ."             </TR>"
     5 0 do
       cr ."             <TR align='center' height='16%'>"
       5 0 do
         cr ."               <TD>"
         j 5 * i +
         .square
         ." </TD>"
       loop
       cr ."             </TR>"
   loop
   cr ."           </TABLE>"
;

\ print n bingo cards
: .cards             \ n --
     .top-html
     0 do
       i dup 2 mod 0=
       if
            cr ."       <TR>"
       then
       cr ."         <TD>"
       .card
       cr ."         </TD>"
       2 mod
       if
            cr ."       </TR>"
       then
     loop
     .bottom-html
;

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Valentine Bingo - Comments? Steve Graham <jsgrahamus@yahoo.com> - 2012-01-26 14:24 -0700
  Re: Valentine Bingo - Comments? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-02-01 23:12 -0800
  Re: Valentine Bingo - Comments? Paul Rubin <no.email@nospam.invalid> - 2012-02-04 21:15 -0800
    Re: Valentine Bingo - Comments? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-02-07 17:59 -0800
    Re: Valentine Bingo - Comments? Steve Graham <jsgrahamus@yahoo.com> - 2012-02-08 07:53 -0700
      Re: Valentine Bingo - Comments? Paul Rubin <no.email@nospam.invalid> - 2012-02-08 10:59 -0800
  Re: Valentine Bingo - Comments? crc <charles.childers@gmail.com> - 2012-02-03 11:35 -0800
  Re: Valentine Bingo - Comments? Steve Graham <jsgrahamus@yahoo.com> - 2012-02-07 07:39 -0700
  Re: Valentine Bingo - Comments? "WJ" <w_a_x_man@yahoo.com> - 2012-03-03 05:32 +0000
    Re: Valentine Bingo - Comments? "Elizabeth D. Rather" <erather@forth.com> - 2012-03-02 21:00 -1000
    Re: Valentine Bingo - Comments? "WJ" <w_a_x_man@yahoo.com> - 2012-03-03 09:21 +0000
      Re: Valentine Bingo - Comments? Paul Rubin <no.email@nospam.invalid> - 2012-03-03 01:26 -0800
        Re: Valentine Bingo - Comments? Josh Grams <josh@qualdan.com> - 2012-03-03 12:52 +0000
          Re: Valentine Bingo - Comments? John Passaniti <john.passaniti@gmail.com> - 2012-03-03 14:08 -0800
            Re: Valentine Bingo - Comments? Paul Rubin <no.email@nospam.invalid> - 2012-03-03 14:41 -0800
              Re: Valentine Bingo - Comments? John Passaniti <john.passaniti@gmail.com> - 2012-03-03 17:39 -0800
                Re: Valentine Bingo - Comments? Paul Rubin <no.email@nospam.invalid> - 2012-03-03 19:18 -0800
                Re: Valentine Bingo - Comments? vandys@vsta.org - 2012-03-05 17:27 +0000
            Re: Valentine Bingo - Comments? "Elizabeth D. Rather" <erather@forth.com> - 2012-03-03 17:51 -1000
            Re: Valentine Bingo - Comments? Josh Grams <josh@qualdan.com> - 2012-03-04 12:29 +0000
              Re: Valentine Bingo - Comments? Rugxulo <rugxulo@gmail.com> - 2012-03-04 07:53 -0800
                Re: Valentine Bingo - Comments? Josh Grams <josh@qualdan.com> - 2012-03-04 17:24 +0000
                Re: Valentine Bingo - Comments? Rugxulo <rugxulo@gmail.com> - 2012-03-04 11:41 -0800
            Re: Valentine Bingo - Comments? Rugxulo <rugxulo@gmail.com> - 2012-03-04 08:16 -0800
              Re: Valentine Bingo - Comments? Bernd Paysan <bernd.paysan@gmx.de> - 2012-03-04 17:39 +0100
                Re: Valentine Bingo - Comments? Bernd Paysan <bernd.paysan@gmx.de> - 2012-03-04 17:42 +0100
              Re: Valentine Bingo - Comments? kenney@cix.compulink.co.uk - 2012-03-05 04:09 -0600
    Re: Valentine Bingo - Comments? Rugxulo <rugxulo@gmail.com> - 2012-03-03 11:35 -0800
    Re: Valentine Bingo - Comments? Doug Hoffman <glidedog@gmail.com> - 2012-03-04 10:07 -0500
      Re: Valentine Bingo - Comments? mhx@iae.nl (Marcel Hendrix) - 2012-03-04 17:42 +0200
        Re: Valentine Bingo - Comments? hwfwguy@gmail.com - 2012-03-06 20:38 -0800
      Re: Valentine Bingo - Comments? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-03-07 22:10 -0800

csiph-web