Solve triangle solitaire puzzle: Difference between revisions
m
→{{header|EasyLang}}
Line 375:
solution$ = ""
#
func try_move pos dir .
if brd$[pos] = "●" and brd$[pos + dir] = "●" and brd$[pos + 2 * dir] = "·"
brd$[pos] = "·"
brd$[pos + dir] = "·"
brd$[pos + 2 * dir] = "●"
.
.
Line 389 ⟶ 387:
brd$[pos + 2 * dir] = "·"
.
func solve .
for pos range len brd$[]
if brd$[pos] = "●"
for dir in [ -13 -11 2 13 11 -2 ]
call try_move pos dir
if
call solve solved
call undo_move pos dir
Line 402 ⟶ 400:
.
.
.
.
▲ if solved = 1 or n_tees = 1
solution$ = str_join brd$[] & solution$
.
.
call solve
print solution$
</lang>
|