Solve the no connection puzzle: Difference between revisions

Content added Content deleted
Line 1,300:
Append Connections, "E":="ABDFGH","F":="HEB", "G":="CDE","H":="DEF"
Inventory ToDelete, Solutions
\\ eliminate double connectionsconnnections
con=each(Connections)
While con {
m$=eval$(con, con^)
c$=eval$(con)
ifIf len(c$)=0"*" thenThen continue
forFor i=1 to len(C$) {
d$=mid$(c$,i,1)
if dr$="*"Filter$(Connections$(d$), then continuem$)
If r$=Filter$(Connections$(d$),<>"" m$)Then {
if r$<>"" then {
Return connections, d$:=r$
} else {
ifIf m$=connections$(d$) thenThen {
Return connections, d$:="*" : ifIf not exist(todelete, d$) thenThen Append todelete, d$
}
}
Line 1,328 ⟶ 1,327:
val=Array(arr, Holes(a$))
con$=Connections$(a$)
res=trueTrue
For i=1 to Len(con$) {
ifIf Abs(Array(Arr, Holes(mid$(con$,i,1)))-val)<2 thenThen res=falseFalse: exitExit
}
=res
Line 1,337 ⟶ 1,336:
h=(,)
solution=(,)
done=falseFalse
counter=0
Print "Waut..."
Line 1,345 ⟶ 1,344:
Print "Solution:";sol^+1
Disp(Eval(Solutions))
aa$=keyKey$
}
Sub P(h, a)
ifIf len(a)<=1 thenThen process(cons(h, a)) : exitExit subSub
local b=cons(a)
For i=1 to len(b) {
Line 1,354 ⟶ 1,353:
P(cons(h,car(b)), cdr(b))
}
End subSub
Sub Process(a)
counter++
Print counter
ifIf keypress(32) thenThen {
local sol=Each(Solutions)
if r$<>"" then { aa$=Key$
While sol {
Print "Solution:";sol^+1
Disp(Eval(Solutions))
aa$=keyKey$
}
}
Line 1,369:
done=True
While hole {
ifIf not CheckValid(Eval$(hole, hole^), a) thenThen done=falseFalse : exitExit
}
ifIf done thenThen Append Solutions, Len(Solutions):=a : Print a
endEnd subSub
Sub Disp(a)
Print format$(" {0} {1}", array(a), array(a,1))
Line 1,383:
Print " \|/ \|/"
Print Format$(" {0} {1}", array(a,6), array(a,7))
End subSub
}
no_connection_puzzle