links from


Sticks! Script
Webb - all rights reserved - ©2004
Author - David Winslow

Summary: Take the last stick and win fame and glory - CODE is FIXED
-There is a  bug in RPN Archive

Instructions: NOTE: Because of a BUG in RPN Archive you
will have to "edit" the code very slightly

[e] D'Enter .aabbcc[ddeeff] [+/-]\where 2 aa,bb...ff 100\e.g. -.070815
or .030507'd1 ;
[e] D'Enter .aabbcc[ddeeff] [+/-]\where 2< aa,bb...ff<100\e.g. -.070815
or .030507'd1 ;

The only change is to add back in the two "<"

          |          |
symbols: 2^aa,bb...ff^100 -
          |          |
          put "less than symbols" in
          these spots ...

I've written Russ about the "less than"
"greater than" RPN Archive bug and he is
looking into it.

A long long time ago I read about this game
in an article by Martin Gardner in his wonderful
column (now, sadly, no longer) "Mathematical
Games and Recreations" in Scientific American.

The game is played with from 3 to 6 piles of
sticks. Each pile has from 3 to 99 sticks. You
may specify who moves first. If it is your move,
you pick a pile and remove as many sticks as you
want to from that pile (you can even remove ALL
the sticks from the pile). Then, RPN will do the
same thing ... Whoever takes the last stick WINS.

Here's what you see and how to enter games
and moves.

-------   Suppose you want 3 piles with 3, 5
| Setup |  and 7 sticks and you want to play
|       |  first. Enter .030507 and tap "Setup".
| Play  |  If you want RPN to move first then
-------   enter .030507 +/- and tap "Setup".

NOTE: Enter .aabbcc[ddeeff] [+|-] where
      2 < aa,bb,cc < 100 and
      bracketed material is optional. Then
      tap "Setup" to enter the game definition

      Include bracketed material to increase
      the number of piles and to specify
      who moves first.

To make a move, tap the number of piles, the
decimal point, and two digits for the number
of sticks: example 3.02 means remove 2 sticks
from pile 3. Then tap "Play".

NOTE: Enter p.nn and tap "Play" to make a move.
      p indicates the pile number and nn is
      the number of sticks. For pile three and
      two sticks enter 3.02 and NOT 3.2 (pile
      3 and 20 sticks)

Sample game: 3-5-7 you move first.

Taps                   What happens

                   ---- -------

.030507 Setup          Dialog: You go first
                       Stack:  0.030507 = tos

3.03 Play              1.02 appears briefly
                       to show RPN's move

                       Stack: 0.010504 = tos

2.02 Play              3.02 appears briefly
                       to show RPN's move

                       Stack: 0.010302 = tos

2.03 Play              3.01 appears briefly
                       to show RPN's move

                       Stack: 0.010001 = tos

1.01 Play              3.01 appears briefly
                       to show RPN's move

                       Dialog: I win

                       Stack: 0.000000 = tos

hmmmmmm .... RPN wins

OK, good luck!


First try the "traditional" game of 3-5-7
and choose to go first=> .030507 Setup

If you cannot win, then try letting
RPN go first=> .030507 +/- Setup

Note the exceptional way that RPN plays !!

After you think you have it, try 3-5-7 with
you moving first. Once you have mastered
3-5-7 you can increase the piles and the number
of sticks in each pile.

Another game to try is -.070815 (it is possible
to win this game). You could also try today's
date for a game: .07111999 - but, better not
let RPN go first on this game or you will have
a tough time winning.

The best settings for RPN are:

   Set "Places (X)" to 2 * (the number of piles)
   and do not "Strip zeros"

Want to know the secret? Want to know the
general strategy behind this game?

Drop me a line and I will be glad to send
you the algorithm and commented code. You can
make money at bars if you know this game well.


RPN.2.z-3 \Sticks
[a] xmXzxmV0{_xzv1+x@+v1+V};
[d] D'Enter p.nn where\p is the pile number\and nn is the number of
sticks.' ;
[e] D'Enter .aabbcc[ddeeff] [+/-]\where 2< aa,bb...ff< 100\e.g. -.070815
or .030507'd1 ;

[p] #'10'r2P;



[u] 2r2P;
h0=0(Ce.)VCcvwb0>(Ce.)v0>(1:2)XhvbfCjxm3<(Ce.:xm6>(Ce.) )Cnxh2=0
(D'I go flrst.|Ok|'d1CrCiCn:D'You go first.|p.nn and then Play|'d1);
CiCng10=0(D'You win'd1.)CrCiCng10=0(D'I win'd1.);

0.0055 secs

top of page

Webb - all rights reserved - ©2004
powered by Spinneret 0.10