A mixed bag of Brainteasers in this EUG, the series is now finally drawing close to its conclusion. Hoorah!
SAINTS TO SINNERS
Here is a musical test for the members of your family who have a keen ear for a tune.
The object of the game is to guess the tune being played and to make it easy, to begin with, we have allowed your computer to play the entire tune. After the first ten 'numbers' you will only hear a short snatch from the tune.
We have included a very large selection of tunes suitable for 'saints and sinners'.
To make life more difficult for the player we have entered the tunes using a special code, so that they cannot be guessed at in advance.
How To Play
When you think that you have guessed the title of the tune being played correctly, type in the full title, press RETURN and find out if your ear is musical or tin.
Programming Hints
Lines 200-400 contain the procedure that plays the tune. The notes of the tune are held in the first and second, if any, elements of the array A$ and the name of the tune is held in N$. W is the indicator determining which tune is to be played. The tune stored in array A$ is terminated by the letters XXXXX. If more than one element of the array is needed to store the tune, the first element is terminated by the letters NNNNN.
Storing data in a string variable is a very useful trick when there are too many fields to be assigned to use DATA statements, as you will be accessing data randomly, not sequentially. See the section entitled Possible alterations for further details.
The obvious alterations that can be made are that when you know the names of the tunes you will want to change them. If you wish to increase the number of tunes that can be played then you must increase the maximum value of W held in line 100. You could then include your tune between 380 and 390 starting with a statement ensuring that the tune is skipped over if the value of W is ensuring that the tune is skipped over if the value of W is not the correct one. You could then work out the tune you require on an instrument, or else you could copy a musical score. If you are copying a musical score then you should refer to the User Guide, but if you are doing it for fun then I recommend a child's musical instrument which usually just has the octave which starts with middle C which is the most common octave. The pitch numbers for this octave are: Middle C = 053, D = 061, E = 069, F = 073, G = 081, A = 089, B = 097 and C = 101.
The duration of the notes should be smaller numbers than specified in the User Guide as processing the array takes time. Therefore I suggest that the durations should be 03, 08 and 18 approximately for notes of short, middle or long duration. When you have worked out the pitch and duration of all the notes, you should assign them to the first and, if more room is required, the second element of the array. The pitch number must have three digits and the duration must have two and they should be joined together and separated from details of the next note by a space. As stated before, the first element is terminated by NNNNN and the second element by XXXXX.
I do not expect you will bother to put the name of the tune in code, but in case you do N$ is made up of the ASCII values of the letters of the name of the tune, remembering to include spaces which have an ASCII value of 32. If you do not bother to code the name of the tune, assign the name to NAM$ and make sure the program skips to line 120.
FRACTION CHASER
We might have named this program "Duel" after the film of the same name as, like the hero of the film, you are being chased by a juggernaut driver.
As you turn right, the juggernaut turns right; turn left and it still follows you.
Coming up in the near distance is an archway. You must escape through the arch before the lumbering truck rolls over you.
Your only answer is to work out how far across the road the centre of the arch is. Guess wrongly and you hit the arch damaging your car. Too many wrong guesses and your car will be immobilised leaving you the defenceless victim of the fast approaching juggernaut.
How To Play
The computer will think of a number whose numerator (top half) and denominator (bottom half) are both ten or less. You must guess the correct fraction and enter it in using the / symbol (eg 2/3) and RETURN. If your guess is too big or too small, you'll be told. The guess closest to the correct answer will be displayed on the arch. The lower guess will be shown on the left hand pillar and the higher guess, closest to the correct answer, will be shown on the right hand pillar.
If your answer is displayed on the arch then you know that you are almost correct. You have nine lives.
This is more difficult than it sounds, after all do you know which is the larger, 3/8 or 4/9? You will be amazing at what you find out about fractions. A hint is that to make a fraction bigger, increase its numerator (top half) or reduce its denominator (bottom half) or both. Do the opposite to make a fraction smaller.
Programming Hints
To make this game easier, reduce the range of fractions allowed. This is done by reducing the tens in line 230. To make it more difficult you may increase these numbers to maximum values of 99 each.
If you want to allow more guesses, increase the 9 in line 280.