Last active
April 19, 2025 02:15
-
-
Save fu-sen/c2fd7b0aae668f029c62bfb66139bbc5 to your computer and use it in GitHub Desktop.
15 Puzzle - SHARP POCKET COMPUTER PC-E200/G series BASIC https://poke-com.jimdofree.com/basic-%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 ' 15 Puzzle | SHARP POCKET COMPUTER PC-E200 / G series BASIC | |
| 2 ' Copyright (c) 2025 BALLOON | FU-SEN | |
| 3 ' The MIT License (MIT) - https://mit.balloon.net.eu.org/#2025 | |
| 100 CLS :RANDOMIZE :DIM D(16):S=100 | |
| 110 FOR I=1 TO 16:D(I)=I:NEXT I | |
| 120 FOR L=1 TO S:GOSUB 310 | |
| 130 R= RND 4 | |
| 140 ON R GOSUB 360,370,380,390 | |
| 150 IF C=U GOTO 130 | |
| 160 T=D(C):D(C)=D(U):D(U)=T | |
| 170 NEXT L:GOSUB 310:S=0 | |
| 180 LOCATE 13,0:PRINT "COUNT" | |
| 190 LOCATE 13,1:PRINT S:L=16 | |
| 200 IF D(L)<>L GOTO 230 | |
| 210 L=L-1:IF L>0 GOTO 200 | |
| 220 LOCATE 12,1:END | |
| 230 I$= INKEY$ | |
| 240 IF I$= CHR$ (4) OR I$="8" GOSUB 360 | |
| 250 IF I$= CHR$ (14) OR I$="6" GOSUB 370 | |
| 260 IF I$= CHR$ (5) OR I$="2" GOSUB 380 | |
| 270 IF I$= CHR$ (15) OR I$="4" GOSUB 390 | |
| 280 IF C=U GOTO 230 | |
| 290 T=D(C):D(C)=D(U):D(U)=T | |
| 300 S=S+1:GOSUB 310:GOTO 180 | |
| 310 LOCATE 0,0:FOR I=1 TO 16 | |
| 320 IF D(I)=16 PRINT " ..";:U=I:GOTO 340 | |
| 330 PRINT USING "###";D(I); | |
| 340 IF I=4 OR I=8 OR I=12 PRINT | |
| 350 NEXT :USING :RETURN | |
| 360 C=U+(U>4)*4:RETURN | |
| 370 C=U-(U- INT (U/4)*4>0):RETURN | |
| 380 C=U-(U<13)*4:RETURN | |
| 390 C=U+(U- INT (U/4)*4<>1):RETURN |
Author
fu-sen
commented
Jan 22, 2025

Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment