Solve triangle solitaire puzzle: Difference between revisions

m
m (→‎{{header|Wren}}: Minor tidy)
(24 intermediate revisions by 5 users not shown)
Line 23:
 
Reference picture:   http://www.joenord.com/puzzles/peggame/
<br/>Updated link (June 2021): &nbsp;
https://www.joenord.com/triangle-peg-board-game-solutions-to-amaze-your-friends/
 
 
Line 34 ⟶ 36:
{{trans|Python}}
 
<langsyntaxhighlight lang="11l">F DrawBoard(board)
V peg = [‘’] * 16
L(n) 1.<16
Line 112 ⟶ 114:
AddPeg(&board, land)
DrawBoard(board)
print("Peg #. jumped over #. to land on #.\n".format(hex(peg), hex(over), hex(land)))</langsyntaxhighlight>
 
{{out}}
Line 211 ⟶ 213:
=={{header|D}}==
{{trans|Ruby}}
<langsyntaxhighlight lang="d">import std.stdio, std.array, std.string, std.range, std.algorithm;
 
immutable N = [0,1,1,1,1,1,1,1,1,1,1,1,1,1,1];
Line 263 ⟶ 265:
}
writeln(l.empty ? "No solution found." : l);
}</langsyntaxhighlight>
{{out}}
<pre>
Line 363 ⟶ 365:
0 0 1 0 0
Solved</pre>
 
=={{header|EasyLang}}==
<syntaxhighlight lang="text">
brd$[] = strchars "
┏━━━━━━━━━┓
┃ · ┃
┃ ● ● ┃
┃ ● ● ● ┃
┃ ● ● ● ● ┃
┃● ● ● ● ●┃
┗━━━━━━━━━┛"
proc solve . solution$ .
solution$ = ""
for pos = 1 to len brd$[]
if brd$[pos] = "●"
npegs += 1
for dir in [ -13 -11 2 13 11 -2 ]
if brd$[pos + dir] = "●" and brd$[pos + 2 * dir] = "·"
brd$[pos] = "·"
brd$[pos + dir] = "·"
brd$[pos + 2 * dir] = "●"
solve solution$
brd$[pos] = "●"
brd$[pos + dir] = "●"
brd$[pos + 2 * dir] = "·"
if solution$ <> ""
solution$ = strjoin brd$[] & solution$
return
.
.
.
.
.
if npegs = 1
solution$ = strjoin brd$[]
.
.
solve solution$
print solution$
</syntaxhighlight>
 
=={{header|Elixir}}==
Inspired by Ruby
<langsyntaxhighlight lang="elixir">defmodule IQ_Puzzle do
def task(i \\ 0, n \\ 5) do
fmt = Enum.map_join(1..n, fn i ->
Line 408 ⟶ 450:
end
 
IQ_Puzzle.task</langsyntaxhighlight>
 
{{out}}
Line 513 ⟶ 555:
=={{header|Go}}==
{{trans|Kotlin}}
<langsyntaxhighlight lang="go">package main
 
import "fmt"
Line 627 ⟶ 669:
fmt.Printf("Peg %X jumped over %X to land on %X\n\n", peg, over, land)
}
}</langsyntaxhighlight>
 
{{out}}
Line 635 ⟶ 677:
 
=={{header|J}}==
<syntaxhighlight lang="j">
<lang J>
NB. This is a direct translation of the python program,
NB. except for the display which by move is horizontal.
Line 817 ⟶ 859:
NB. Solution NB. return Solution however Solution is global.
)
</syntaxhighlight>
</lang>
Example linux session with program in file CrackerBarrel.ijs
<pre>
Line 856 ⟶ 898:
Print one possible solution.
 
<syntaxhighlight lang="java">
<lang Java>
import java.util.ArrayList;
import java.util.Arrays;
Line 1,044 ⟶ 1,086:
 
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,082 ⟶ 1,124:
=={{header|Julia}}==
{{trans|Raku}}
<langsyntaxhighlight lang="julia">moves = [[1, 2, 4], [1, 3, 6], [2, 4, 7], [2, 5, 9], [3, 5, 8], [3, 6, 10], [4, 5, 6],
[4, 7, 11], [4, 8, 13], [5, 8, 12], [5, 9, 14], [6, 9, 13], [6, 10, 15],
[7, 8, 9], [8, 9, 10], [11, 12, 13], [12, 13, 14], [13, 14, 15]]
Line 1,118 ⟶ 1,160:
end
end
</langsyntaxhighlight>{{out}}
<pre>
Starting board:
Line 1,221 ⟶ 1,263:
=={{header|Kotlin}}==
{{trans|Python}}
<langsyntaxhighlight lang="scala">// version 1.1.3
 
data class Solution(val peg: Int, val over: Int, val land: Int)
Line 1,296 ⟶ 1,338:
println("Peg %X jumped over %X to land on %X\n".format(peg, over, land))
}
}</langsyntaxhighlight>
 
{{out}}
Line 1,400 ⟶ 1,442:
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">ClearAll[Showstate]
Showstate[state_List, pos_] := Module[{p, e},
p = {#, FirstPosition[pos, #, Missing[], {2}]} & /@ state;
Line 1,445 ⟶ 1,487:
state = DeleteCases[Range[15], x];
continue = True;
SolvePuzzle[{state, {}}, {y}]</langsyntaxhighlight>
{{out}}
Outputs a graphical overview, by clicking one can go through the different states.
Line 1,451 ⟶ 1,493:
=={{header|Nim}}==
{{trans|Go}}
<langsyntaxhighlight Nimlang="nim">import sequtils, strutils
 
type
Line 1,526 ⟶ 1,568:
board[land] = true
board.draw()
echo "Peg $1 jumped over $2 to land on $3\n".format(peg.toHex(1), over.toHex(1), land.toHex(1))</langsyntaxhighlight>
 
{{out}}
Line 1,629 ⟶ 1,671:
=={{header|Perl}}==
{{trans|Raku}}
<langsyntaxhighlight lang="perl">@start = qw<
0
1 1
Line 1,680 ⟶ 1,722:
 
print $result ? $result : "No solution found";
</syntaxhighlight>
</lang>
{{out}}
<pre style="height:60ex;overflow:scroll;">Starting with
Line 1,800 ⟶ 1,842:
Twee brute-force string-based solution. Backtracks a mere 366 times, whereas starting with the 5th peg missing backtracks 19388 times (all in 0s, obvs).
 
<!--<langsyntaxhighlight Phixlang="phix">-->
<span style="color: #000080;font-style:italic;">-- demo\rosetta\IQpuzzle.exw</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">moves</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{-</span><span style="color: #000000;">11</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">9</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">11</span><span style="color: #0000FF;">,</span><span style="color: #000000;">9</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">2</span><span style="color: #0000FF;">}</span>
Line 1,830 ⟶ 1,872:
"""</span>
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">join_by</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">split</span><span style="color: #0000FF;">(</span><span style="color: #000000;">start</span><span style="color: #0000FF;">&</span><span style="color: #000000;">solve</span><span style="color: #0000FF;">(</span><span style="color: #000000;">start</span><span style="color: #0000FF;">,</span><span style="color: #000000;">14</span><span style="color: #0000FF;">),</span><span style="color: #008000;">'\n'</span><span style="color: #0000FF;">),</span><span style="color: #000000;">5</span><span style="color: #0000FF;">,</span><span style="color: #000000;">7</span><span style="color: #0000FF;">),</span><span style="color: #008000;">"-"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">" "</span><span style="color: #0000FF;">))</span>
<!--</langsyntaxhighlight>-->
 
{{out}}
Line 1,848 ⟶ 1,890:
Adapted to the English game (also in demo\rosetta\IQpuzzle.exw):
 
<!--<langsyntaxhighlight Phixlang="phix">-->
<span style="color: #008080;">constant</span> <span style="color: #000000;">moves</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{-</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">15</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">15</span><span style="color: #0000FF;">}</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">solve</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">board</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">integer</span> <span style="color: #000000;">left</span><span style="color: #0000FF;">)</span>
Line 1,883 ⟶ 1,925:
"""</span>
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">join_by</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">split</span><span style="color: #0000FF;">(</span><span style="color: #000000;">start</span><span style="color: #0000FF;">&</span><span style="color: #000000;">solve</span><span style="color: #0000FF;">(</span><span style="color: #000000;">start</span><span style="color: #0000FF;">,</span><span style="color: #000000;">32</span><span style="color: #0000FF;">),</span><span style="color: #008000;">'\n'</span><span style="color: #0000FF;">),</span><span style="color: #000000;">7</span><span style="color: #0000FF;">,</span><span style="color: #000000;">8</span><span style="color: #0000FF;">),</span><span style="color: #008000;">"-"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">" "</span><span style="color: #0000FF;">))</span>
<!--</langsyntaxhighlight>-->
 
{{out}}
Line 1,919 ⟶ 1,961:
o . . . o o o o o o o o o o o o o o o o o o o o
</pre>
 
=={{header|Picat}}==
This version use the constraint solver (cp).
<syntaxhighlight lang="picat">import cp.
 
go =>
% Solve the puzzle
puzzle(1,N,NumMoves,X,Y),
println("Show the moves (Move from .. over .. to .. ):"),
foreach({From,Over,To} in X)
println([from=From,over=Over,to=To])
end,
nl,
println("Show the list at each move (0 is an empty hole):"),
foreach(Row in Y)
foreach(J in 1..15)
printf("%2d ", Row[J])
end,
nl
end,
nl,
 
println("And an verbose version:"),
foreach(Move in 1..NumMoves)
if Move > 1 then
printf("Move from %d over %d to %d\n",X[Move-1,1],X[Move-1,2],X[Move-1,3])
end,
nl,
print_board([Y[Move,J] : J in 1..N]),
nl
end,
nl,
% fail, % uncomment to see all solutions
nl.
 
puzzle(Empty,N,NumMoves,X,Y) =>
N = 15,
 
% Peg 1 can move over 2 and end at 4, etc
% (for table_in/2)
moves(Moves),
ValidMoves = [],
foreach(From in 1..N)
foreach([Over,To] in Moves[From])
ValidMoves := ValidMoves ++ [{From,Over,To}]
end
end,
 
NumMoves = N-1,
 
% which move to make
X = new_array(NumMoves-1,3),
X :: 1..N,
 
% The board at move Move
Y = new_array(NumMoves,N),
Y :: 0..N,
 
% Initialize for row
Y[1,Empty] #= 0,
foreach(J in 1..N)
if J != Empty then
Y[1,J] #= J
end
end,
 
% make the moves
foreach(Move in 2..NumMoves)
sum([Y[Move,J] #=0 : J in 1..N]) #= Move,
table_in({From,Over,To}, ValidMoves),
 
% Get this move and update the rows
element(To,Y[Move-1],0),
element(From,Y[Move-1],FromVal), FromVal #!= 0,
element(Over,Y[Move-1],OverVal), OverVal #!= 0,
 
element(From,Y[Move],0),
element(To,Y[Move],To),
element(Over,Y[Move],0),
 
foreach(J in 1..N)
(J #!= From #/\ J #!= Over #/\ J #!= To) #=>
Y[Move,J] #= Y[Move-1,J]
end,
X[Move-1,1] #= From,
X[Move-1,2] #= Over,
X[Move-1,3] #= To
end,
 
Vars = Y.vars() ++ X.vars(),
solve($[split],Vars).
 
%
% The valid moves:
% Peg 1 can move over 2 and end at 4, etc.
%
moves(Moves) =>
Moves = [
[[2,4],[3,6]], % 1
[[4,7],[5,9]], % 2
[[5,8],[6,10]], % 3
[[2,1],[5,6],[7,11],[8,13]], % 4
[[8,12],[9,14]], % 5
[[3,1],[5,4],[9,13],[10,15]], % 6
[[4,2],[8,9]], % 7
[[5,3],[9,10]], % 8
[[5,2],[8,7]], % 9
[[6,3],[9,8]], % 10
[[7,4],[12,13]], % 11
[[8,5],[13,14]], % 12
[[8,4],[9,6],[12,11],[14,15]], % 13
[[9,5],[13,12]], % 14
[[10,6],[14,13]] % 15
].
 
%
% Print the board:
%
% 1
% 2 3
% 4 5 6
% 7 8 9 10
% 11 12 13 14 15
%
print_board(B) =>
printf(" %2d\n", B[1]),
printf(" %2d %2d\n", B[2],B[3]),
printf(" %2d %2d %2d\n", B[4],B[5],B[6]),
printf(" %2d %2d %2d %2d\n",B[7],B[8],B[9],B[10]),
printf(" %2d %2d %2d %2d %2d\n",B[11],B[12],B[13],B[14],B[15]),
nl.</syntaxhighlight>
 
{{out}}
<pre>Show the moves (Move from .. over .. to .. ):
[from = 4,over = 2,to = 1]
[from = 6,over = 5,to = 4]
[from = 1,over = 3,to = 6]
[from = 12,over = 8,to = 5]
[from = 14,over = 13,to = 12]
[from = 6,over = 9,to = 13]
[from = 12,over = 13,to = 14]
[from = 15,over = 10,to = 6]
[from = 7,over = 4,to = 2]
[from = 2,over = 5,to = 9]
[from = 6,over = 9,to = 13]
[from = 14,over = 13,to = 12]
[from = 11,over = 12,to = 13]
 
Show the list at each move (0 is an empty hole):
0 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 0 3 0 5 6 7 8 9 10 11 12 13 14 15
1 0 3 4 0 0 7 8 9 10 11 12 13 14 15
0 0 0 4 0 6 7 8 9 10 11 12 13 14 15
0 0 0 4 5 6 7 0 9 10 11 0 13 14 15
0 0 0 4 5 6 7 0 9 10 11 12 0 0 15
0 0 0 4 5 0 7 0 0 10 11 12 13 0 15
0 0 0 4 5 0 7 0 0 10 11 0 0 14 15
0 0 0 4 5 6 7 0 0 0 11 0 0 14 0
0 2 0 0 5 6 0 0 0 0 11 0 0 14 0
0 0 0 0 0 6 0 0 9 0 11 0 0 14 0
0 0 0 0 0 0 0 0 0 0 11 0 13 14 0
0 0 0 0 0 0 0 0 0 0 11 12 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 13 0 0
 
And an verbose version:
 
0
2 3
4 5 6
7 8 9 10
11 12 13 14 15
 
 
Move from 4 over 2 to 1
 
1
0 3
0 5 6
7 8 9 10
11 12 13 14 15
 
 
Move from 6 over 5 to 4
 
1
0 3
4 0 0
7 8 9 10
11 12 13 14 15
 
 
Move from 1 over 3 to 6
 
0
0 0
4 0 6
7 8 9 10
11 12 13 14 15
 
 
Move from 12 over 8 to 5
 
0
0 0
4 5 6
7 0 9 10
11 0 13 14 15
 
 
Move from 14 over 13 to 12
 
0
0 0
4 5 6
7 0 9 10
11 12 0 0 15
 
 
Move from 6 over 9 to 13
 
0
0 0
4 5 0
7 0 0 10
11 12 13 0 15
 
 
Move from 12 over 13 to 14
 
0
0 0
4 5 0
7 0 0 10
11 0 0 14 15
 
 
Move from 15 over 10 to 6
 
0
0 0
4 5 6
7 0 0 0
11 0 0 14 0
 
 
Move from 7 over 4 to 2
 
0
2 0
0 5 6
0 0 0 0
11 0 0 14 0
 
 
Move from 2 over 5 to 9
 
0
0 0
0 0 6
0 0 9 0
11 0 0 14 0
 
 
Move from 6 over 9 to 13
 
0
0 0
0 0 0
0 0 0 0
11 0 13 14 0
 
 
Move from 14 over 13 to 12
 
0
0 0
0 0 0
0 0 0 0
11 12 0 0 0
 
 
Move from 11 over 12 to 13
 
0
0 0
0 0 0
0 0 0 0
0 0 13 0 0</pre>
 
=={{header|Prolog}}==
Works with SWI-Prolog and module(lambda).
 
<langsyntaxhighlight Prologlang="prolog">:- use_module(library(lambda)).
 
iq_puzzle :-
Line 2,019 ⟶ 2,350:
select(End, Free, F1),
display(Tail, [Start, Middle | F1]).
</syntaxhighlight>
</lang>
Output :
<pre> ?- iq_puzzle.
Line 2,141 ⟶ 2,472:
=={{header|Python}}==
 
<syntaxhighlight lang="python">#
<lang Python>#
# Draw board triangle in ascii
#
Line 2,236 ⟶ 2,567:
AddPeg(board,land) # board order changes!
DrawBoard(board)
print "Peg %X jumped over %X to land on %X\n" % (peg,over,land)</langsyntaxhighlight>
 
{{out}}
Line 2,341 ⟶ 2,672:
Oh and there are some useful triangle numbers functions thrown in for free!
 
<langsyntaxhighlight lang="racket">#lang racket
(define << arithmetic-shift)
(define bwbs? bitwise-bit-set?)
Line 2,419 ⟶ 2,750:
 
;; Solve #1 missing -> #13 left alone
(for-each display-board (find-path (flip-peg 1 full-board) (flip-peg 13 empty-board)))</langsyntaxhighlight>
 
{{out}}
Line 2,506 ⟶ 2,837:
{{trans|Sidef}}
 
<syntaxhighlight lang="raku" line>
<lang perl6>
constant @start = <
0
Line 2,556 ⟶ 2,887:
last if $result
};
say $result ?? $result !! "No solution found";</langsyntaxhighlight>
{{out}}
<pre style="height:60ex;overflow:scroll;">Starting with
Line 2,660 ⟶ 2,991:
=={{header|Ruby}}==
 
<langsyntaxhighlight lang="ruby"># Solitaire Like Puzzle Solver - Nigel Galloway: October 18th., 2014
G = [[0,1,3],[0,2,5],[1,3,6],[1,4,8],[2,4,7],[2,5,9],[3,4,5],[3,6,10],[3,7,12],[4,7,11],[4,8,13],[5,8,12],[5,9,14],[6,7,8],[7,8,9],[10,11,12],[11,12,13],[12,13,14],
[3,1,0],[5,2,0],[6,3,1],[8,4,1],[7,4,2],[9,5,2],[5,4,3],[10,6,3],[12,7,3],[11,7,4],[13,8,4],[12,8,5],[14,9,5],[8,7,6],[9,8,7],[12,11,10],[13,12,11],[14,13,12]]
Line 2,674 ⟶ 3,005:
l=false; G.each{|g| l=solve(N,N.inject(:+),g); break if l}
puts l ? l : "No solution found"
</syntaxhighlight>
</lang>
{{out}}
<pre style="height:64ex;overflow:scroll">
Line 2,779 ⟶ 3,110:
=={{header|Sidef}}==
{{trans|Ruby}}
<langsyntaxhighlight lang="ruby">const N = [0,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
 
const G = [
Line 2,818 ⟶ 3,149:
var r = ''
G.each {|g| (r = solve(N, 1, g)) && break }
say (r ? r : "No solution found")</langsyntaxhighlight>
 
{{out}}
Line 2,925 ⟶ 3,256:
'''Notes:'''
This program uses a brute-force method with a string of 25 characters to internally represent the 15 spots on the peg board. One can set the starting removed peg and intended last remaining peg by editing the header variable declarations named '''''Starting''''' and '''''Target'''''. If one doesn't care which spot the last peg lands on, the '''''Target''''' variable can be set to 0. The constant '''''n''''' can be changed for different sized peg boards, for example with '''''n = 6''''' the peg board would have 21 positions.
<langsyntaxhighlight lang="vbnet">
Imports System, Microsoft.VisualBasic.DateAndTime
 
Line 3,051 ⟶ 3,382:
If Diagnostics.Debugger.IsAttached Then Console.ReadLine()
End Sub
End Module</langsyntaxhighlight>
{{out}}
'''A full solution:'''
Line 3,157 ⟶ 3,488:
{{trans|Kotlin}}
{{libheader|Wren-fmt}}
<langsyntaxhighlight ecmascriptlang="wren">import "./fmt" for Conv, Fmt
 
var board = List.filled(16, true)
Line 3,236 ⟶ 3,567:
drawBoard.call()
Fmt.print("Peg $X jumped over $X to land on $X\n", peg, over, land)
}</langsyntaxhighlight>
 
{{out}}
Line 3,242 ⟶ 3,573:
Same as Kotlin entry.
</pre>
 
=={{header|Yabasic}}==
{{trans|Phix}}
<syntaxhighlight lang="yabasic">// Rosetta Code problem: http://rosettacode.org/wiki/Solve_triangle_solitare_puzzle
// by Galileo, 04/2022
 
dim moves$(1)
 
nmov = token("-11,-9,2,11,9,-2", moves$(), ",")
 
sub solve$(board$, left)
local i, j, mj, over, tgt, res$
if left = 1 return ""
for i = 1 to len(board$)
if mid$(board$, i, 1) = "1" then
for j = 1 to nmov
mj = val(moves$(j)) : over = i + mj : tgt = i + 2 * mj
if tgt >= 1 and tgt <= len(board$) and mid$(board$, tgt, 1) = "0" and mid$(board$, over, 1) = "1" then
mid$(board$, i, 1) = "0" : mid$(board$, over, 1) = "0" : mid$(board$, tgt, 1) = "1"
res$ = solve$(board$, left - 1)
if len(res$) != 4 return board$+res$
mid$(board$, i, 1) = "1" : mid$(board$, over, 1) = "1" : mid$(board$, tgt, 1) = "0"
end if
next
end if
next
return "oops"
end sub
start$ = "\n\n 0 \n 1 1 \n 1 1 1 \n 1 1 1 1 \n1 1 1 1 1"
print start$, solve$(start$, 14)</syntaxhighlight>
{{out}}
<pre>
 
0
1 1
1 1 1
1 1 1 1
1 1 1 1 1
 
1
0 1
0 1 1
1 1 1 1
1 1 1 1 1
 
1
0 1
1 0 0
1 1 1 1
1 1 1 1 1
 
0
0 0
1 0 1
1 1 1 1
1 1 1 1 1
 
0
1 0
0 0 1
0 1 1 1
1 1 1 1 1
 
0
1 1
0 0 0
0 1 1 0
1 1 1 1 1
 
0
1 1
0 1 0
0 0 1 0
1 0 1 1 1
 
0
1 1
0 1 1
0 0 0 0
1 0 0 1 1
 
0
0 1
0 0 1
0 0 1 0
1 0 0 1 1
 
0
0 0
0 0 0
0 0 1 1
1 0 0 1 1
 
0
0 0
0 0 1
0 0 1 0
1 0 0 1 0
 
0
0 0
0 0 0
0 0 0 0
1 0 1 1 0
 
0
0 0
0 0 0
0 0 0 0
1 1 0 0 0
 
0
0 0
0 0 0
0 0 0 0
0 0 1 0 0
---Program done, press RETURN---</pre>
 
=={{header|zkl}}==
{{trans|D}}
{{Trans|Ruby}}
<langsyntaxhighlight lang="zkl">var N=T(0,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
var G=T( T(0,1, 3), T(0,2, 5), T(1,3, 6), T( 1, 4, 8), T( 2, 4, 7), T( 2, 5, 9),
T(3,4, 5), T(3,6,10), T(3,7,12), T( 4, 7,11), T( 4, 8,13), T( 5, 8,12),
Line 3,280 ⟶ 3,730:
reg l;
foreach g in (G){ if(l=solve(N,1,g)) break; }
println(l and l or "No solution found.");</langsyntaxhighlight>
{{out}}
<pre style="height:32ex;overflow:scroll">
9,476

edits