This following program is one where you should deny yourself, and any other player, the use of paper and pencil if you really want some mental exercise.
The screen will display a four by four matrix of numbers to the left hand side. On the right hand side will be shown a number, or numbers, in red.
You have to combine two, or more, of the numbers in any of the rows to arrive at the same figure as the red number/s.
How to play
To reach your answer you may use any of the following operators:
+ plus
- minus
* multiplication
/ division
^ to the power of
SQR square root of
Example: If the red number is 1 and the row is 9 2 4 8 the solution would be
SQR(9)+2-4
This, followed by RETURN, would give 1 as it's answer.
Correct answers will mean that you will be asked if you wish to proceed. Answer Y or No followed by RETURN.
If you answer incorrectly, your computer will explain, and show, the correct solution.
A score sheet appears after 200 seconds which will show your results and give an IQ rating against your reasoning powers.
Programming hints
The matrix is displayed in double height, double width characters. This is done by using Mode 5 to give double width characters and then defining 20 user defined characters which consist of the top halves of the numbers 0 to 9 and the bottom halves of the numbers 0 to 9. The pattern for the numbers 0 to 9 is found by calling the OSWORD routine with the hexadecimal number A in the accumulator (%A). The OSWORD routine is at &FFF1. See the User Guide for further details if you are not familiar with machine code or the ROM routines.
If you wish to increase the number of rows or columns of the matrix then you must change the maximum value of I (row) or J (column) in the FOR . . . NEXT loops.
10 REM RELATIONS 20 REM COPYRIGHT (C) G.LUDINSKI 1983 30 REM ON ERROR PROC_ERROR:GOTO 830 40 MODE5:VDU23;8202;0;0;0;19,1,0;0;19 ,2,0;0;19,3,0;0; 50 DIM A(4,4),X(16),Y(16) 60 CLS 70 REM 80 REM CREATE DOUBLE HEIGHT CHARACTER S 90 REM 100 A%=&A 110 X%=0:Y%=&A 120 FOR I=0 TO 9 130 ?&A00=ASC(STR$(I)) 140 CALL (&FFF1) 150 VDU23,128+(2*I),?&A01,?&A01,?&A0 2,?&A02,?&A03,?&A03,?&A04,?&A04 160 VDU23,128+(2*I)+1,?&A05,?&A05,?& A06,?&A06,?&A07,?&A07,?&A08,?&A08 170 NEXT I 180 TIME=0:NO=0:CR=0 190 REM 200 REM GENERATE NUMBERS 210 REM 220 CLS 230 PRINT'" Relations" 240 PRINT' 250 IF TIME >= 20000 THEN GOTO 890 260 NO=NO+1 270 FOR I=1 TO 4 280 FOR J=1 TO 4 290 A(I,J)=RND(9) 300 NEXT J 310 NEXT I 320 REM 330 REM DISPLAY NUMBERS 340 REM 350 COLOUR128:COLOUR2 360 FOR I=1 TO 4 370 PRINT 380 FOR T=1 TO 2 390 FOR J=1 TO 4 400 IF T=1 THEN PRINT" ";CHR$(12 8+(2*A(I,J))); 410 IF T=2 THEN PRINT" ";CHR$(12 8+(2*A(I,J))+1); 420 NEXT J 430 PRINT 440 NEXT T 450 NEXT I 460 REM 470 REM GENERATE RED NUMBER 480 REM 490 S1=RND(2):S2=INT(RND(1)*10):SM=VAL (STR$(S1)+STR$(S2)) 500 COLOUR 1 510 PRINTTAB(13,9);CHR$(128+(2*S1));CH R$(128+(2*S2)) 520 PRINTTAB(13,10);CHR$(128+(2*S1)+1) ;CHR$(128+(2*S2)+1) 530 COLOUR3 540 REM 550 REM CHECK ANSWER 560 REM 570 PRINTTAB(0,17)"Combine a row or column to be equal to the red number" 580 PRINT 590 PRINT"Use + - * / ^ SQR ()" 600 VDU19,1,1;0;19,2,3;0;19,3,7;0; 610 INPUT'I$ 620 IF I$="" THEN PROC_ERROR:GOTO 830 630 IF EVAL(I$) <> SM THEN PRINT'"No,t hey are not = ";SM:GOTO830 640 N$="" 650 FOR I=1 TO LEN(I$) 660 NU$=MID$(I$,I,1) 670 IF NU$ >= "0" AND NU$ <= "9" THE N N$=N$+NU$ 680 NEXT I 690 IF LEN(N$) > 4 OR LEN(N$) = 0 THEN PROC_ERROR:GOTO830 700 SG$="" 710 FOR T=1 TO 2 720 FOR I=1 TO 4 730 SG$=SG$+"X" 740 FOR J=1 TO 4 750 IF T=1 THEN SG$=SG$+STR$(A(I ,J)) 760 IF T=2 THEN SG$=SG$+STR$(A(J ,I)) 770 NEXT J 780 NEXT I 790 SG$=SG$+"X" 800 NEXT T 810 IF INSTR(SG$,N$)=0 THEN PROC_ERROR :GOTO830 820 PRINT:PRINT"Yes, you're right":CR= CR+1 830 PRINT:PRINT"Do you want more Y/N"; 840 INPUT R$ 850 IF R$ <> "N" THEN GOTO220 860 REM 870 REM SCORE SHEET 880 REM 890 CLS 900 TM=TIME/100 910 PRINT'"Number attempted=";NO 920 PRINT'"Number correct=";CR 930 PRINT'"Time taken=";INT(TM);"secs" 940 IQ=INT((CR*100)/5.3):IF IQ > 150 T HEN IQ=150 950 PRINT'"IQ lvl (reasoning)=";IQ 960 IF CR >= 7 THEN PRINT'"This is SUP ERIOR (upper 10%)":END 970 IF CR = 6 THEN PRINT'"This is GOOD (upper 30%)":END 980 IF CR > 4 THEN PRINT'"This is FAIR (upper 60%)":END 990 GOTO1030 1000 DEFPROC_ERROR 1010 PRINTTAB(0,26)"Error, wrong number s" 1020 ENDPROC 1030 END 1040 REM
N.B. In lines 110 - 160 inclusive, you will see & and ?. Do not confuse these with numbers 8 and 7.