5 REM PRINT TAB(33);"BAGELS"
10 REM PRINT TAB(15);"CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY":PRINT:PRINT
15 REM *** BAGLES NUMBER GUESSING GAME
20 REM *** ORIGINAL SOURCE UNKNOWN BUT SUSPECTED TO BE
25 REM *** LAWRENCE HALL OF SCIENCE, U.C. BERKELY
30 REM DIM A1(6),A(3),B(3)
40 Y=0:T=255
50 REM PRINT:PRINT:PRINT
70 INPUT "WOULD YOU LIKE THE RULES (YES=1 NO=0)? ";A
90 IF A=0 THEN GOTO 150
100 PRINT: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 @(I)=RND(10))
165 IF I-1=0 THEN GOTO 200
170 FOR J=1 TO I-1
180 IF @(I)=@(J) THEN GOTO 160
190 NEXT J
200 NEXT I
210 PRINT:PRINT "O.K.  I HAVE A NUMBER IN MIND." : PRINT
220 FOR I=1 TO 20
230 PRINT "GUESS #";I
240 INPUT A
250 FOR Z=3 TO 1 STEP -1 : @(10+Z)=A%10 : A=A/10 : NEXT Z
320 IF @(11)=@(12) THEN GOTO 650
330 IF @(12)=@(13) THEN GOTO 650
340 IF @(13)=@(14) THEN GOTO 650
350 C=0:D=0
360 FOR J=1 TO 2
370 IF @(J)#@(J+11) THEN GOTO 390
380 C=C+1
390 IF @(J+1)#@(J+10) THEN GOTO 410
400 C=C+1
410 NEXT J
420 IF @(1)#@(13) THEN GOTO 440
430 C=C+1
440 IF @(3)#@(11) THEN GOTO 460
450 C=C+1
460 FOR J=1 TO 3
470 IF @(J)#@(J+10) THEN GOTO 490
480 D=D+1
490 NEXT J
500 IF D=3 THEN GOTO 680
505 IF C=0 THEN GOTO 545
520 FOR J=1 TO C
530 PRINT "PICO ";
540 NEXT J
545 IF D=0 THEN GOTO 580
550 FOR J=1 TO D
560 PRINT "FERMI ";
570 NEXT J
580 IF C+D#0 THEN GOTO 600
590 PRINT "BAGELS";
600 PRINT
605 NEXT I
610 PRINT "OH WELL."
615 PRINT "THAT'S TWENTY GUESSES.  MY NUMBER WAS";100*@(1)+10*@(2)+@(3)
620 GOTO 700
630 PRINT "TRY GUESSING A THREE-DIGIT NUMBER.":GOTO 230
650 PRINT "OH, I FORGOT TO TELL YOU THAT THE NUMBER I HAVE IN MIND"
660 PRINT "HAS NO TWO DIGITS THE SAME.":GOTO 230
680 PRINT "YOU GOT IT!!!":PRINT
690 Y=Y+1
700 INPUT "PLAY AGAIN (YES=1 NO=0)? ";A
720 IF A=1 THEN GOTO 150
730 IF Y=0 THEN GOTO 750
740 PRINT:PRINT "A ";Y;" POINT BAGELS BUFF!!"
750 PRINT "HOPE YOU HAD FUN.  BYE."
999 END