Post Reply 
I was bored and found a HP-27S
06-28-2014, 12:35 AM
Post: #68
RE: I was bored and found a HP-27S
(06-27-2014 10:58 PM)jebem Wrote:  However, I must confess that the way Thomas and others here take advantage of the Solve feature really puzzles me...

That is understandable. Thomas and I have been working with the solver for years and over that period we have found tricks to capitalize on its features to do things that would not be possible in a simpler solver application, and also to do things that the designer probably didn't count on (like exiting a loop early by doing an illegal operation like divide by 0).

A simpler solver is able to solve equations, like Pythagorean theorem:
SQ(A)+SQ(B)=SQ(C)

Enter value for A, press A. Enter value for B, press B. Then press C and it calculates the value of C. If you enter a number before pressing the menu key, it just assigns the value you entered to that variable. But if you don't enter a value before pressing the menu key, it evaluates the equation and tells you the value the variable must have in order to solve the equation. If you don't have an equals sign in your equation, it tells you the value that the variable must have so that the equation equals 0.

Read the manual to see how the S command works (Solving for). The general form of that is: IF(S(A): calculate A here - A: calculate B here - B).

Here is a simple solver equation for playing the famous "high/low" guessing game. The calculator thinks of a number between 0 and 99, and you try to guess it.

First, after CALC'ing the equation, press INIT. This sets the number of guesses to 0 and loads N with a random number, 0-99. [this takes advantage of the RAN# solver function on the 27S and 19b; on the 17b/17bii, there is no random number function so getting a random number takes more work, but it can be done using CTIME]

So, INIT generates the random number you will try to guess. So enter your first guess and press GUESS. That just stores the value you entered in the variable GUESS, it doesn't execute any code. Then press EVAL for evaluate. This executes code. It increments the guess counter G by 1. It then checks your guess against the random number N. If it is equal, it returns the number of guesses you required (and you are done). If your guess is too low, it returns 0, else your guess is too high and it returns 99.

This is what the code would look like on the 27S:

Code:

IF(S(INIT):L(G:0)XL(N:IP(100XRAN#))-INIT:
0XL(G:G(G)+1)+IF(GUESS=G(N):G(G):IF(GUESS<G(N):0:99))-EVAL)

Unless I have made an error above (which is possible since I don't have a 27s to test on), this should let you play the high/low game. You should always guess the number within 7 guesses if you use a binary search approach, by the way.

This is a simple example of using the solver to play a game, something not possible on a traditional equation solver.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
I was bored and found a HP-27S - jebem - 06-09-2014, 10:38 PM
RE: I was bored and found a HP-27S - jebem - 06-10-2014, 09:35 AM
RE: I was bored and found a HP-27S - jebem - 06-25-2014, 06:49 PM
RE: I was bored and found a HP-27S - jebem - 06-26-2014, 01:44 PM
RE: I was bored and found a HP-27S - jebem - 06-26-2014, 01:40 PM
RE: I was bored and found a HP-27S - jebem - 06-26-2014, 03:57 PM
RE: I was bored and found a HP-27S - jebem - 06-27-2014, 01:15 PM
RE: I was bored and found a HP-27S - jebem - 06-27-2014, 08:50 PM
RE: I was bored and found a HP-27S - HP67 - 06-27-2014, 02:56 PM
RE: I was bored and found a HP-27S - HP67 - 06-27-2014, 03:28 PM
RE: I was bored and found a HP-27S - jebem - 06-27-2014, 10:18 PM
RE: I was bored and found a HP-27S - jebem - 06-27-2014, 10:58 PM
RE: I was bored and found a HP-27S - Don Shepherd - 06-28-2014 12:35 AM
RE: I was bored and found a HP-27S - jebem - 06-28-2014, 08:02 AM
RE: I was bored and found a HP-27S - jebem - 06-27-2014, 10:46 PM
RE: I was bored and found a HP-27S - jebem - 06-28-2014, 07:55 AM
RE: I was bored and found a HP-27S - jebem - 06-27-2014, 10:56 PM
RE: I was bored and found a HP-27S - jebem - 06-27-2014, 11:05 PM
RE: I was bored and found a HP-27S - jebem - 06-28-2014, 04:44 PM
RE: I was bored and found a HP-27S - jebem - 06-28-2014, 05:37 PM
HP-27S that does not turn on - franz.b - 11-06-2020, 08:24 PM
RE: I was bored and found a HP-27S - jebem - 11-09-2020, 07:14 AM



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