Solve triangle solitaire puzzle: Difference between revisions

m
m (syntax highlighting fixup automation)
m (→‎{{header|Wren}}: Minor tidy)
(6 intermediate revisions by 2 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 365 ⟶ 367:
 
=={{header|EasyLang}}==
<syntaxhighlight lang="text">brd$[] = strchars "
brd$[] = strchars "
┏━━━━━━━━━┓
┃ · ┃
Line 373 ⟶ 376:
┃● ● ● ● ●┃
┗━━━━━━━━━┛"
funcproc solve . solution$ .
solution$ = ""
for pos range= 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] = "●"
call solve solution$
brd$[pos] = "●"
brd$[pos + dir] = "●"
brd$[pos + 2 * dir] = "·"
if solution$ <> ""
solution$ = strjoin brd$[] & solution$
break 3 return
.
.
.
.
.
if npegs = 1
.
solution$ = strjoin brd$[]
if npegs = 1
.
solution$ = strjoin brd$[]
.
.
call solve solution$
print solution$
</syntaxhighlight>
Line 3,485 ⟶ 3,488:
{{trans|Kotlin}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Conv, Fmt
 
var board = List.filled(16, true)
9,483

edits