Tuesday, December 11, 2012

Petit Computer Picross


I'm curious of how well can people copying code from text as opposed to just scan QR code. So, this will come only as source code, no QR. Let's see how well you can copy this, and hopefully understand it. I won't be explaining anything. The source code tells all!
Major bragging rights to the first person who can change P[] array to meaningful numbers. 
PS: I did this in 2 hours pecking at the screen with the stylus! How far can you go? Keep pushing!
CLS:CLEAR
DIM P[16]
GOSUB @INIT
GOSUB @DISP
@LOOP
GOSUB @PANE
GOSUB @MOVE
IF G$==P$ GOTO @END
GOTO @LOOP
@END
BEEP 7:LOCATE 18,18:?"WIN!"
FOR I=1 TO 1:VSYNC 1:I=BUTTON(3):NEXT
END
@MOVE
FOR I=1 TO 1:VSYNC 1:B=BUTTON(3):I=B:NEXT
BEEP 66
IF B AND 32 THEN G$=SUBST$(G$,CY*16+CX,1,"0")
IF B AND 16 THEN G$=SUBST$(G$,CY*16+CX,1,"1")
IF B AND 1 THEN CY=CY+15
IF B AND 2 THEN CY=CY+1
IF B AND 4 THEN CX=CX+15
IF B AND 8 THEN CX=CX+1
CX=CX%16:CY=CY%16
SPOFS 1,CX*8,CY*8
RETURN
@PANE
FOR I=0 TO 15:FOR J=0 TO 15
LOCATE J,I
IF "0"==MID$(G$,I*16+J,1) THEN ?CHR$(32) ELSE ?CHR$(224)
NEXT:NEXT
RETURN
@DISP
CLS
FOR I=0 TO 255 STEP 16
H$="":C=0
FOR J=0 TO 15
IF "1"==MID$(P$,I+J,1) THEN C=C+1
IF "0"==MID$(p$,I+J,1) THEN IF C THEN H$=H$+STR$(C):C=0
NEXT
IF C THEN H$=H$+STR$(C)
LOCATE 17,I/16:?H$
NEXT
FOR I=0 TO 15
H$="":C=0
FOR J=0 TO 15
IF "1"==MID$(P$,I+(J*16),1) THEN C=C+1
IF "0"==MID$(p$,I+(J*16),1) THEN IF C THEN H$=H$+STR$(C):C=0
NEXT
IF C THEN H$=H$+STR$(C)
FOR J=0 TO LEN(H$)
LOCATE I,16+J:?MID$(H$,J,1);
NEXT
NEXT
RETURN
@INIT
P[0]=2016
P[1]=14364
P[2]=16770
P[3]=33729
P[4]=35793
P[5]=40377
P[6]=24186
P[7]=19506
P[8]=12300
P[9]=21066
P[10]=18834
P[11]=38505
P[12]=44085
P[13]=25638
P[14]=24582
P[15]=4104
FOR I=0 TO 15
V=P[I]:T$=""
FOR J=0 TO 15
T$=STR$(V%2)+T$:V=FLOOR(V/2)
NEXT
P$=P$+T$
NEXT
G$="0"*LEN(P$)
SPSET 1,156,0,0,0,0,16,16
SPANIM 1,4,15
SPSCALE 1,50
CX=0:CY=0
RETURN

2 comments:

Anonymous said...

I copied it but it says missing opperand 41 mid$

Simpleton Geek said...

IF "0"==MID$(p$,I+(J*16),1) THEN IF C THEN H$=H$+STR$(C):C=0

That's all in one line, not two. Also, it seems that I left the string variable in lowercase, where it should be upper case. Next time you run into trouble, try to debug it yourself, and let me know what you did, instead of saying it doesn't work.

Very hard for me to know where the mistake lies since it's possible that the mistake lies somewhere other than what lines the computer says.