Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 10 DIM A%(140,140): CI=0: SX=70: SY=70
- 20 PRINT "Loading data...": GOSUB 60: PRINT "Part 1:";: GOSUB 140: PRINT N
- 30 FOR R=1 TO 100: PRINT R;":";: GOSUB 170: PRINT "Done";: GOSUB 140: PRINT N
- 40 NEXT: PRINT "Part 2:";N: END
- 50 REM *************************
- 60 OPEN "I", 1, "data24.txt": WHILE NOT EOF(1): LINE INPUT #1,S$: CX=SX: CY=SY
- 70 FOR I = 1 TO LEN(S$): C$ = MID$(S$,I,1)
- 80 IF C$="e" THEN CX=CX+1: GOTO 120
- 90 IF C$="w" THEN CX=CX-1: GOTO 120
- 100 IF C$="s" THEN CY=CY+1: CX=CX-1 ELSE CY=CY-1
- 110 I=I+1: C$ = MID$(S$,I,1): IF C$="e" THEN CX=CX+1
- 120 NEXT I: A%(CX,CY) = 1 - A%(CX,CY): PRINT ".";: WEND: PRINT: RETURN
- 130 REM *************************
- 140 N=0: FOR Y=0 TO 140: FOR X=0 TO 140: IF A%(X,Y) MOD 2=1 THEN N=N+1
- 150 NEXT: NEXT: RETURN
- 160 REM *************************
- 170 FOR Y=1 TO 139: FOR X=1 TO 139: N = 0
- 180 FOR DX=-1 TO 1: FOR DY=-1 TO 1: IF DX<>DY THEN N=N+(A%(X+DX,Y+DY) MOD 2)
- 190 NEXT: NEXT: IF N=2 OR (N=1 AND A%(X,Y)=1) THEN A%(X,Y)=A%(X,Y)+256
- 200 NEXT: NEXT: FOR Y=1 TO 139: FOR X=1 TO 139: A%(X,Y)=A%(X,Y)\256: NEXT: NEXT
- 210 RETURN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement