Solve the no connection puzzle: Difference between revisions
Content deleted Content added
No edit summary |
|||
Line 1,287: | Line 1,287: | ||
=={{header|M2000 Interpreter}}== |
=={{header|M2000 Interpreter}}== |
||
Addition a reducing algorithm for double connections, if A has D then from D we remove A unless D has only A so we remove D from A, unless A has only D. |
|||
<lang M2000 Interpreter> |
<lang M2000 Interpreter> |
||
Module no_connection_puzzle { |
Module no_connection_puzzle { |
||
Line 1,293: | Line 1,294: | ||
Append Connections, "E":="ABDFGH","F":="HEB", "G":="CDE","H":="DEF" |
Append Connections, "E":="ABDFGH","F":="HEB", "G":="CDE","H":="DEF" |
||
\\ eliminate double connections |
|||
While con { |
|||
m$=eval$(con, con^) |
|||
c$=eval$(con) |
|||
for i=1 to len(C$) { |
|||
d$=mid$(c$,i,1) |
|||
r$=Filter$(Connections$(d$), m$) |
|||
if r$="" then { |
|||
c1$=filter$(c$, d$) |
|||
if c1$<>"" then Return connections, m$:=c1$: c$=c1$ |
|||
} else { |
|||
Return connections, d$:=r$ |
|||
} |
|||
} |
|||
} |
|||
Inventory Holes |
Inventory Holes |
||
For i=0 to 7 : Append Holes, Chr$(65+i):=i : Next i |
For i=0 to 7 : Append Holes, Chr$(65+i):=i : Next i |
||
Line 1,356: | Line 1,372: | ||
4 6 |
4 6 |
||
</pre > |
</pre > |
||
=={{header|Mathematica}}== |
=={{header|Mathematica}}== |
||
This one simply takes all permutations of the pegs and filters out invalid solutions. |
This one simply takes all permutations of the pegs and filters out invalid solutions. |