Xah Lee, 2006-07

## My First Program and the 8-Queens Puzzle

In about 1991, i bought the HP-28s calculator for something like \$250. It was introduced in 1988 and is the first calculator that is capable of symbolic computation. For example, you can use it to solve a quadratic equation symbolically. And, it is also one of the first graphing calculator, if not the very first. This is a RPN calculator, and is also a programable calculator.

The HP-28s calculator. (image source: The Museum of HP Calculators by David G Hicks.)

It is actualy the HP-28s that i did my first programing. I never took any programing course, but am a avid learner of math and computer stuff. I read the manuals from cover to cover.

My first program is a program to solve the Eight queens puzzle. It was a puzzle posted to CompuServe's math forum. At the time, i'm also a crazy fan of recreational math. I took it upon myself to solve this by programing my super calculator to automatically generate the solution.

The 8-queens puzzle is typically solved by a back-tracking algorithm. This is what i did, even though at the time i know nothing about computer science or programing. (see: Xah Lee's Computing Experience Bio) Also, a couple years later i realized, that there is a bug in my program. That is, my program misses some solutions.

Here's my code for the 8-queens puzzle:

HP-28S Advanced Scientific Calculator Owner's Manual (1988). amazon

## Music Chord Program

Around 1991, i'm taking music classes. One of the things in music theory and training, is to understand the various chords, and being able to identify by ear. The HP-28s is capable of playing simple beeps of various frequencies. Thus, i actually wrote a relatively large program that plays musical chords and scales.

What follows below is a introduction from the documentation i wrote:

These programs can spell and play any triad or seventh chords. You type-in a chord and have the calculator to play it by pressing PLAY1, PLAY2, PLAY3 or spelled out by pressing SPELL. By pressing CHORD, HP-28 will generate a triad or 7th chord randomly. For example, you key in "A M " and press PLAY1, HP-28 will play a A major triad.

(Enharmonic chords with roots on E#, B#, Fb, Cb are not generated by CHORD but can be arguments of SPELL or PLAY. Enharmonic chords using double sharp or double flat as roots are not generated nor recognized. These programs can be used on HP-28s (and probably would work in HP-48s, HP-48sx, HP-48G, and HP-48GX models).

Chords to be PLAYed or SPELLed must be typed in as a string format: "Note" + "AccidentalSign" + "Quality". For example, A sharp major 7th is entered as "A#M7". A major triad is entered as "A M ".

Here is a table showing all the chords starting with roots of A, Ab, and A#. Chords starting with other keys are similarly entered.

...

```"M" = Major
"m" = minor
"+" = augumented
"h" = half-diminished.
"∞" = dimished
Spaces in the string can be left out.```

This system of programs also allows you to key in the duration of each note to be played, in increment of 1/100th seconds. You can also change the ratio between adjacent notes to get 24 note per octave micro turning or other strange effects. To do so, simply change the value stored in DUR or R. For more information, see the variable diagrams in Section 3 of this book. This system will be expanded in later version. The following functions are good candidates for expansion: play chord progressions, play scales, identify chords, invert/retrograde/augument/diminition of melodies, metronome, tuning machine. Readers are welcome to send in their .expansion programs.

You can download the full documentation and program here: HP-28S_music_chords.doc.zip . The file is a Microsoft Word document, which you can open with the free OpenOffice.org software.

## Misc Programs

I've wrote a bunch of other simple programs that helps me study math in college. Here they are, in image format from screenshot of Microsoft Word doc around 2000.