summaryrefslogtreecommitdiffstats
path: root/development/minimal-basic/examples/BAGELS.BAS
diff options
context:
space:
mode:
Diffstat (limited to 'development/minimal-basic/examples/BAGELS.BAS')
-rw-r--r--development/minimal-basic/examples/BAGELS.BAS117
1 files changed, 117 insertions, 0 deletions
diff --git a/development/minimal-basic/examples/BAGELS.BAS b/development/minimal-basic/examples/BAGELS.BAS
new file mode 100644
index 0000000000..edd64d77a7
--- /dev/null
+++ b/development/minimal-basic/examples/BAGELS.BAS
@@ -0,0 +1,117 @@
+1 RANDOMIZE
+5 PRINT TAB(33);"BAGELS"
+10 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
+12 PRINT TAB(10);"ECMA-55 PORT BY. B. WATSON, URCHLAY AT SLACKWARE.UK"
+14 PRINT
+16 PRINT
+20 REM *** BAGELS NUMBER GUESSING GAME
+22 REM *** ORIGINAL SOURCE UNKNOWN BUT SUSPECTED TO BE
+25 REM *** LAWRENCE HALL OF SCIENCE, U.C. BERKELEY
+29 REM A = ACTUAL ANSWER, G = USER'S GUESS
+30 DIM A(3),G(3)
+40 LET Y=0
+50 PRINT
+55 PRINT
+60 PRINT
+70 PRINT "WOULD YOU LIKE THE RULES (1=YES, 0=NO)";
+80 INPUT N
+90 IF N=0 THEN 150
+100 PRINT
+105 PRINT "I AM THINKING OF A THREE-DIGIT NUMBER. TRY TO GUESS"
+110 PRINT "MY NUMBER AND I WILL GIVE YOU CLUES AS FOLLOWS:"
+120 PRINT " PICO - ONE DIGIT CORRECT BUT IN THE WRONG POSITION"
+130 PRINT " FERMI - ONE DIGIT CORRECT AND IN THE RIGHT POSITION"
+140 PRINT " BAGELS - NO DIGITS CORRECT"
+150 FOR I=1 TO 3
+160 LET A(I)=INT(10*RND)
+165 IF I-1=0 THEN 200
+170 FOR J=1 TO I-1
+180 IF A(I)=A(J) THEN 160
+190 NEXT J
+200 NEXT I
+210 PRINT
+215 PRINT "O.K. I HAVE A NUMBER IN MIND."
+220 FOR I=1 TO 20
+230 PRINT "GUESS #";I,
+240 INPUT N
+243 IF N>=1000 THEN 247
+245 IF N<0 THEN 247
+246 GOTO 250
+247 GOSUB 630
+248 GOTO 230
+250 LET G(1)=INT(N/100)
+260 LET G(2)=INT((N-G(1)*100)/10)
+270 LET G(3)=N-(G(1)*100+G(2)*10)
+290 REM UNCOMMENT NEXT LINE FOR DEBUGGING
+300 REM GOSUB 800
+320 LET F=0
+322 IF G(1)<>G(2) THEN 330
+325 LET F=1
+330 IF G(2)<>G(3) THEN 340
+335 LET F=1
+340 IF G(3)<>G(1) THEN 345
+342 LET F=1
+345 IF F=0 THEN 350
+347 GOSUB 650
+349 GOTO 230
+350 LET C=0
+355 LET D=0
+360 FOR J=1 TO 2
+370 IF A(J)<>G(J+1) THEN 390
+380 LET C=C+1
+390 IF A(J+1)<>G(J) THEN 410
+400 LET C=C+1
+410 NEXT J
+420 IF A(1)<>G(3) THEN 440
+430 LET C=C+1
+440 IF A(3)<>G(1) THEN 460
+450 LET C=C+1
+460 FOR J=1 TO 3
+470 IF A(J)<>G(J) THEN 490
+480 LET D=D+1
+490 NEXT J
+500 IF D=3 THEN 680
+505 IF C=0 THEN 545
+520 FOR J=1 TO C
+530 PRINT "PICO ";
+540 NEXT J
+545 IF D=0 THEN 580
+550 FOR J=1 TO D
+560 PRINT "FERMI ";
+570 NEXT J
+580 IF C+D<>0 THEN 600
+590 PRINT "BAGELS";
+600 PRINT
+605 NEXT I
+610 PRINT "OH WELL."
+612 PRINT "THAT'S TWENTY GUESSES. MY NUMBER WAS";100*A(1)+10*A(2)+A(3)
+614 LET N=100*A(1)+10*A(2)+A(3)
+615 IF N>=100 THEN 620
+617 PRINT "0";
+618 IF N>=10 THEN 620
+619 PRINT "0";
+620 PRINT N
+622 GOTO 700
+630 PRINT "TRY GUESSING A THREE-DIGIT NUMBER."
+635 RETURN
+650 PRINT "OH, I FORGOT TO TELL YOU THAT THE NUMBER I HAVE IN MIND"
+660 PRINT "HAS NO TWO DIGITS THE SAME."
+670 RETURN
+680 PRINT "YOU GOT IT!!!"
+685 PRINT
+690 LET Y=Y+1
+700 PRINT "PLAY AGAIN (1=YES, 0=NO)";
+710 INPUT N
+720 IF N<>0 THEN 150
+730 IF Y=0 THEN 750
+740 PRINT
+745 PRINT "A";Y;"POINT BAGELS BUFF!!"
+750 PRINT "HOPE YOU HAD FUN. BYE."
+760 GOTO 999
+799 REM CHEAT/DEBUG MODE. UNCOMMENT LINE 300 TO ACTIVATE THIS CODE
+800 PRINT "GUESS","ANSWER"
+805 FOR X=1 TO 3
+810 PRINT G(X),A(X)
+820 NEXT X
+830 RETURN
+999 END