REM Scott Kiedeisch
REM Antietam High School
INT DIV
REM ACSL PATHWAYS
DIM grid(0:20,0:20)
DIM g(0:20,0:20)
DIM m$(50,4)
DIM f(50)
DIM f1(50)
PRINT "ENTER THE LOCATION OF THE NODES IN THE
GRAPH:"
DO
INPUT prompt
"ONE LOCATION: ":a,b
IF a<>0 and
b<>0 then LET grid(a,b)=1
LOOP until a=0 and b=0
FOR acsl=1 to 5
MAT g=0
MAT
m$=""
MAT f=0
MAT f1=0
LET path=0
INPUT a,b,c,d
LET depth=1
LET a1=a
LET b1=b
LET f1(1)=1
LET f(1)=1
IF grid(a+1,b)=1
or grid(a-1,b)=1 or grid(a,b+1)=1 or grid(a,b-1)=1 then
DO
IF
f1(depth)>f(depth) or a1=c and b1=d then
IF a1=c
and b1=d then LET path=path+1
LET
g(a1,b1)=0
FOR i=1
to 4
LET
m$(depth,i)=""
NEXT i
LET
f1(depth)=0
LET
depth=depth-1
LET
f1(depth)=f1(depth)+1
IF
depth=1 then
LET
a1=a
LET
b1=b
ELSE
LET
a1=val(m$(depth-1,f1(depth-1))[1:1])
LET
b1=val(m$(depth-1,f1(depth-1))[2:2])
END IF
ELSE
LET e=0
IF
grid(a1+1,b1)=1 and g(a1+1,b1)=0 then
LET
e=e+1
LET
m$(depth,e)=str$(a1+1)&str$(b1)
END IF
IF
grid(a1-1,b1)=1 and g(a1-1,b1)=0 then
LET
e=e+1
LET
m$(depth,e)=str$(a1-1)&str$(b1)
END IF
IF
grid(a1,b1+1)=1 and g(a1,b1+1)=0 then
LET
e=e+1
LET
m$(depth,e)=str$(a1)&str$(b1+1)
END IF
IF
grid(a1,b1-1)=1 and g(a1,b1-1)=0 then
LET
e=e+1
LET
m$(depth,e)=str$(a1)&str$(b1-1)
END IF
LET
f(depth)=e
IF
m$(depth,1)="" then
LET
g(a1,b1)=0
FOR
i=1 to 4
LET m$(depth,i)=""
NEXT
i
LET
depth=depth-1
LET
f1(depth)=f1(depth)+1
IF
depth=1 then
LET a1=a
LET b1=b
ELSE
LET a1=val(m$(depth-1,f1(depth-1))[1:1])
LET b1=val(m$(depth-1,f1(depth-1))[2:2])
END
IF
ELSE
LET g(a1,b1)=1
LET
a1=val(m$(depth,f1(depth))[1:1])
LET
b1=val(m$(depth,f1(depth))[2:2])
LET
f1(depth+1)=1
LET
f(depth+1)=1
LET
depth=depth+1
END IF
END IF
LOOP until
f1(1)>f(1)
END IF
IF path=0 then
PRINT "NONE"
IF path<>0
then PRINT path
NEXT acsl
END