Solve the no connection puzzle: Difference between revisions

Content added Content deleted
(Added Quackery.)
Line 3,742: Line 3,742:
\|/ \|/
\|/ \|/
4 3</pre>
4 3</pre>

=={{header|Quackery}}==

<code>rank->perm</code> and <code>!</code> are defined at [[Permutations/Rank of a permutation#Quackery]].

To display all of the solutions, remove the word <code>conclude</code> from the last line of the code.

<syntaxhighlight lang="Quackery"> [ ' [ [ 0 2 ] [ 0 3 ] [ 0 4 ]
[ 1 3 ] [ 1 4 ] [ 1 5 ]
[ 6 2 ] [ 6 3 ] [ 6 4 ]
[ 7 3 ] [ 7 4 ] [ 7 5 ]
[ 2 3 ] [ 3 4 ] [ 4 5 ] ] ] is connections ( --> [ )

[ dip dup do
unrot peek dip peek - abs 1 = ] is invalid ( [ [ --> b )

[ true swap
connections witheach
[ dip dup invalid if
[ dip not conclude ] ]
drop ] is allvalid ( [ --> b )

say " A B C D E F G H" cr
8 ! times
[ i^ 8 rank->perm
allvalid if
[ sp
i^ 8 rank->perm
witheach
[ sp 1+ echo ]
cr conclude ] ]</syntaxhighlight>

{{out}}

<pre> A B C D E F G H
3 4 7 1 8 2 5 6
</pre>


=={{header|Racket}}==
=={{header|Racket}}==