In 1987 Acorn donated an Archimedes A305 colour system as a prize for our "Alphametics" programming competition. The interest and response to this was so impressive that we propose another competition along similar lines, involving the submission of a program which will be tested for speed and versatility. The competition will be open to all members of BEEBUG and RISC User. All programs will be timed on the same machine, thus making it fair for all. All programs must be written in a subset of BBC Basic which will run on any Acorn machine (except the Atom) without the use of any machine call, indirection operators, or operating system calls. This means that Master owners cannot use ON-PROC, while Archimedes owners must also avoid WHILE, CASE, IF-ENDIF, matrix operations, local error handling, RETURN parameters, local arrays, and the operators +=, -=, *=, /=. Programs may, however, use the standard Basic disc filing commands (DFS or ADFS) providing the file size does not exceed 100k.
Write a program to generate and print an expression using exactly four fours, which will produce the numbers 0 to 50 together with the expressions that generate them. These four fours may be combined in any way, provided that fours are the only digits that appear in the expression. Mathematical symbols are + - * / ^ ( ) . ! R G (R and G represent "Sqr Root" and "Gamma" respectively).
0=4+4-4-4 1=44/44
12=4/.4+4/R4 17=4*(4+R(R4^(-4)))
20=G4-G4+!4-4 48 =!4+!4+4-4
49=(R4+R4/.4)^R4
Where R means "Square Root", ! means "Factorial, and G means "Gamma".
!n=n*(n-1)*(n-2)*...*1 e.g. !4=4*3*2*1=24.
Gn=!(n-1) e.g. G4=!(4-1)=!3=6.
The examples above do not necessarily give the simplest solution. E.g. 20 could be represented more simply as 4*(4+4/4). Your program must be able to be easily changed to work with numbers other than "fours", for instance it should allow four "threes", or four "fives".
Send a postcard to be received by 31st August 1989 containing your Name, Membership Number, Day-time phone number, Time taken for 0-50, and the Machine used.
Send to | BEEBUG A3000 Competition, |
117 Hatfield Road, | |
St Albans, | |
Herts, AL1 4JS |
(please note that this is our new address as from 7th August).
If you are shortlisted, we will then ask you to submit your program, when it will be tested back to back against other programs. Do NOT be put off if you have a slow machine or if your program takes all day to provide expressions, or fails to find all solutions (they may not exist!) this will be taken into account in selecting the shortlist.
Entries will be judged on a combination of the criteria listed below, and the winner must be able to supply a version suitably annotated for publication. BEEBUG will be the sole judge as to whether an entry conforms to the spirit of the competition, and sole judge when determining the winner. BEEBUG's decision will be final. No BEEBUG staff or their relatives are eligible to enter.
1. Speed - the program that finds expressions for the numbers 0 to 50 in the shortest time when run on the same machine as all the other entries.
2. Choosing simplest solutions - The program that gives the simplest expression for each number. Priorities for defining simplicity will be the following order + - * / ^ () . R G "tricks", "approximations". For example the following solutions for the number 1 are graded in order of simplicity:
1 = 44/44
1 = (4*4)/(4*4)
1 = (4/.4)/(4/.4)
1 = G4/G(4-.4+.4)
1 = TAN(44+4/4) classed as a "trick"
1 = 4^(4/44!) classed as an "approximation"
3. Digit Flexibility - The program should be simple to change to make it work for other digits such as four "threes".
4. Range Flexibility - The program should allow the range to be selected so as to find solutions from 50 - 100 say.
We are unable to undertake any correspondence on the competition, however we can supply a sheet expanding on various aspects upon receipt of an SAE.