Post Reply 
(16C) Nimb
08-29-2019, 09:07 AM (This post was last modified: 09-03-2019 07:39 AM by NoEqualsButton.)
Post: #1
(16C) Nimb
An oldie but a goodie. Just what the world needs, Nimb for the HP 16C. This version does not allow the player to cheat!

Enjoy.

Code:

001 g LBL A   | 43 22 A  NIM
002 DEC       | 24
003 3         | 3
004 2         | 2
005 f WSIZE   | 42 44 32 bit decimal
006 1         | 1
007 5         | 5
008 STO 0     | 44 0  Set initial value
009 g LBL 0   | 43 22 0
010 RCL 0     | 45 0
011 R/S       | 31      Get player move
012 g x>y     | 43 3
013 GTO 0     | 22 0      Try again if greater than value
014 3         | 3
015 x<->y     | 34
016 g x>y     | 43 3
017 GTO 0     | 22 0     Try again if greater than 3
018 g x >0    | 43 30
019 GTO 1     | 22 1
020 GTO 0     | 22 0     Try again if LEQ 0
021 g LBL 1   | 43 22 1
022 RCL 0     | 45 0
023 x<->y     | 34
024 -         | 30
025 STO 0     | 44 0        Execute player move
026 g x<>0    | 43 48
027 GTO 2     | 22 2
028 5         | 5
029 5         | 5
030 1         | 1
031 7         | 7
032 8         | 8
033 g RTN     | 43 21      Program won!
034 g LBL 2   | 43 22 2
035 1         | 1            Compute program move
036 -         | 30
037 3         | 3
038 f AND     | 42 20
039 g x=0     | 43 40
040 1         | 1
041 RCL 0     | 45 0
042 x<->y     | 34
043 g PSE     | 43 34       Show program move
044 -         | 30
045 STO 0     | 44 0
046 g x<>0    | 43 48
047 GTO 0     | 22 0        Still moves left
048 3         | 3
049 5         | 5
050 0         | 0
051 7         | 7
052 g RTN     | 43 21      Player has won

Steve

HP11C, HP12C, HP15C, HP16C, HP25, HP32S, HP33C, HP41CV, DM42, HP46, HP65
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)