Solve triangle solitaire puzzle: Difference between revisions
Content added Content deleted
Line 374: | Line 374: | ||
┃● ● ● ● ●┃ |
┃● ● ● ● ●┃ |
||
┗━━━━━━━━━┛" |
┗━━━━━━━━━┛" |
||
proc solve . solution$ . |
|||
solution$ = "" |
solution$ = "" |
||
for pos = 1 to len brd$[] |
for pos = 1 to len brd$[] |
||
if brd$[pos] = "●" |
if brd$[pos] = "●" |
||
npegs += 1 |
npegs += 1 |
||
for dir in [ -13 -11 2 13 11 -2 ] |
for dir in [ -13 -11 2 13 11 -2 ] |
||
if brd$[pos + dir] = "●" and brd$[pos + 2 * dir] = "·" |
if brd$[pos + dir] = "●" and brd$[pos + 2 * dir] = "·" |
||
brd$[pos] = "·" |
brd$[pos] = "·" |
||
brd$[pos + dir] = "·" |
brd$[pos + dir] = "·" |
||
brd$[pos + 2 * dir] = "●" |
brd$[pos + 2 * dir] = "●" |
||
call solve solution$ |
call solve solution$ |
||
brd$[pos] = "●" |
brd$[pos] = "●" |
||
brd$[pos + dir] = "●" |
brd$[pos + dir] = "●" |
||
brd$[pos + 2 * dir] = "·" |
brd$[pos + 2 * dir] = "·" |
||
if solution$ <> "" |
if solution$ <> "" |
||
solution$ = strjoin brd$[] & solution$ |
solution$ = strjoin brd$[] & solution$ |
||
break 3 |
break 3 |
||
. |
. |
||
. |
. |
||
. |
|||
. |
. |
||
. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
. |
|||
. |
. |
||
call solve solution$ |
call solve solution$ |