{this program site did not run the whole peg solitare of me http://e...content-available-to-author-only...a.org/wiki/Peg_solitaire becauuse of time
limit exceed therefore i used a small o shaped structure like this
. . .
* * *
. * * . * * .
. * . . . * .
. * * . * * .
* * *
. . . }
{here '.' dots represets make moves and '*' represents which is to nove rest you lrn from wikipedia}
{also if want to add full solitare then you can run on free pascal compiler download "geany" and run this code by editing it}
{all coments are requested to gauravalgo@gmail.com}
{how to see please see the resuts from bottom of the page to top }
{beacuse of its recursive nature i am configuring it for new version}
{enjoy the play at facebook!! :) }
program io;
{$APPTYPE CONSOLE}
{$ExtendedSyntax On}
uses
SysUtils;
{ TODO -oUser -cConsole Main : Insert code here }
{dedining dynamic array of characters}
type
pegboard = Array [ 1 .. 7 , 1 .. 7 ] of Char ;
var
global: Array [ 1 .. 100 , 1 .. 3 ] of Integer ;
type
moves = Array [ 1 .. 4 , 1 .. 2 ] of integer ;
var
m : moves = ( ( - 2 , 0 ) ,
( 0 , + 2 ) ,
( + 2 , 0 ) ,
( 0 , - 2 ) ) ;
procedure place ( row, col, dir: integer ; var tempboard: pegboard) ;
begin
if dir= 1 then
begin
tempboard[ row, col] : = '.' ;
tempboard[ row+ m[ 1 , 1 ] + 1 , col+ m[ 1 , 2 ] ] : = '.' ;
tempboard[ row+ m[ 1 , 1 ] , col+ m[ 1 , 2 ] ] : = '*' ;
end ;
if dir= 2 then
begin
tempboard[ row, col] : = '.' ;
tempboard[ row+ m[ 2 , 1 ] , col+ m[ 2 , 2 ] - 1 ] : = '.' ;
tempboard[ row+ m[ 2 , 1 ] , col+ m[ 2 , 2 ] ] : = '*' ;
end ;
if dir= 3 then
begin
tempboard[ row, col] : = '.' ;
tempboard[ row+ m[ 3 , 1 ] - 1 , col+ m[ 3 , 2 ] ] : = '.' ;
tempboard[ row+ m[ 3 , 1 ] , col+ m[ 3 , 2 ] ] : = '*' ;
end ;
if dir= 4 then
begin
tempboard[ row, col] : = '.' ;
tempboard[ row+ m[ 4 , 1 ] , col+ m[ 4 , 2 ] + 1 ] : = '.' ;
tempboard[ row+ m[ 4 , 1 ] , col+ m[ 4 , 2 ] ] : = '*' ;
end ;
end ;
procedure unplace ( row, col, dir: integer ; var tempboard: pegboard) ;
begin
if dir= 1 then
begin
tempboard[ row, col] : = '*' ;
tempboard[ row+ m[ 1 , 1 ] + 1 , col+ m[ 1 , 2 ] ] : = '*' ;
tempboard[ row+ m[ 1 , 1 ] , col+ m[ 1 , 2 ] ] : = '.' ;
end ;
if dir= 2 then
begin
tempboard[ row, col] : = '*' ;
tempboard[ row+ m[ 2 , 1 ] , col+ m[ 2 , 2 ] - 1 ] : = '*' ;
tempboard[ row+ m[ 2 , 1 ] , col+ m[ 2 , 2 ] ] : = '.' ;
end ;
if dir= 3 then
begin
tempboard[ row, col] : = '*' ;
tempboard[ row+ m[ 3 , 1 ] - 1 , col+ m[ 3 , 2 ] ] : = '*' ;
tempboard[ row+ m[ 3 , 1 ] , col+ m[ 3 , 2 ] ] : = '.' ;
end ;
if dir= 4 then
begin
tempboard[ row, col] : = '*' ;
tempboard[ row+ m[ 4 , 1 ] , col+ m[ 4 , 2 ] + 1 ] : = '*' ;
tempboard[ row+ m[ 4 , 1 ] , col+ m[ 4 , 2 ] ] : = '.' ;
end ;
end ;
function count ( tempboard : pegboard) : integer ;
var
i, j : integer ;
counter: integer ;
begin
counter: = 0 ;
for i: = 1 to 7 do
begin
for j: = 1 to 7 do
begin
if tempboard[ i, j] = '*' then
begin
inc( counter) ;
end ;
end ;
end ;
count: = counter;
end ;
procedure show ( tempboard : pegboard) ;
var
i, j : integer ;
begin
for i: = 1 to 7 do
begin
for j: = 1 to 7 do
begin
Write ( tempboard[ i, j] , ' ' ) ;
end ;
Writeln ;
end ;
end ;
function testValid( temppegboard: pegboard) : integer ;
var
f, k: integer ;
row1, col1, i, j: integer ;
begin
f: = 0 ;
for i: = 1 to 7 do
begin
for j: = 1 to 7 do
begin
if temppegboard[ i, j] = '*' then
begin
row1: = i;
col1: = j;
for k: = 1 to 4 do
begin
row1: = row1+ m[ k, 1 ] ;
col1: = col1+ m[ k, 2 ] ;
if ( ( row1>0 ) and ( col1 >0 ) and ( row1<8 ) and ( col1<8 ) ) then
begin
if ( ( k= 1 ) and ( temppegboard[ row1+ 1 , col1] = '*' ) and ( temppegboard[ row1, col1] = '.' ) ) then
begin
global[ f+ 1 , 1 ] : = i;
global[ f+ 1 , 2 ] : = j;
global[ f+ 1 , 3 ] : = 1 ;
Inc( f) ;
end ;
if ( ( k= 2 ) and ( temppegboard[ row1, col1- 1 ] = '*' ) and ( temppegboard[ row1, col1] = '.' ) ) then
begin
global[ f+ 1 , 1 ] : = i;
global[ f+ 1 , 2 ] : = j;
global[ f+ 1 , 3 ] : = 2 ;
Inc( f) ;
end ;
if ( ( k= 3 ) and ( temppegboard[ row1- 1 , col1] = '*' ) and ( temppegboard[ row1, col1] = '.' ) ) then
begin
global[ f+ 1 , 1 ] : = i;
global[ f+ 1 , 2 ] : = j;
global[ f+ 1 , 3 ] : = 3 ;
Inc( f) ;
end ;
if ( ( k= 4 ) and ( temppegboard[ row1, col1+ 1 ] = '*' ) and ( temppegboard[ row1, col1] = '.' ) ) then
begin
global[ f+ 1 , 1 ] : = i;
global[ f+ 1 , 2 ] : = j;
global[ f+ 1 , 3 ] : = 4 ;
Inc( f) ;
end ;
end ;
row1: = i;
col1: = j;
end ;
end ;
end ;
end ;
testValid: = f;
end ;
function pegsolver( row, col, dir: integer ; tempboard: pegboard) : integer ;
var
counter, i, r: integer ;
begin
counter : = testValid( tempboard) ;
i: = 1 ;
while i<= counter do
begin
row: = global[ i, 1 ] ;
col: = global[ i, 2 ] ;
dir: = global[ i, 3 ] ;
place( row, col, dir, tempboard) ;
if count( tempboard) = 1 then
begin
writeln ( 'row1= ' , row, ' col1= ' , col) ;
show( tempboard) ;
writeln ;
pegsolver: = 1 ;
exit;
end ;
r: = pegsolver( row, col, dir, tempboard) ;
if r= 1 then
begin
writeln ( 'row1= ' , row, ' col1= ' , col) ;
show( tempboard) ;
writeln ;
pegsolver: = 1 ;
exit;
end ;
unplace( row, col, dir, tempboard) ;
counter: = testValid( tempboard) ;
inc( i) ;
end ;
pegsolver: = 0 ;
end ;
var
p : pegboard=
( ( ' ' , ' ' , '.' , '.' , '.' , ' ' , ' ' ) ,
( ' ' , ' ' , '*' , '*' , '*' , ' ' , ' ' ) ,
( '.' , '*' , '*' , '.' , '*' , '*' , '.' ) ,
( '.' , '*' , '.' , '.' , '.' , '*' , '.' ) ,
( '.' , '*' , '*' , '.' , '*' , '*' , '.' ) ,
( ' ' , ' ' , '*' , '*' , '*' , ' ' , ' ' ) ,
( ' ' , ' ' , '.' , '.' , '.' , ' ' , ' ' ) ) ;
temppegboard : pegboard;
var
i, j , re, row, col, dir: integer ;
begin
row: = 1 ;
col: = 1 ;
dir: = 1 ;
for i: = 1 to 7 do
begin
for j: = 1 to 7 do
begin
temppegboard[ i, j] : = p[ i, j] ;
end ;
end ;
re: = pegsolver( row, col, dir, temppegboard) ;
writeln ( 'start solving...' ) ;
show( temppegboard) ;
writeln ( re) ;
readln ;
end .
e3RoaXMgcHJvZ3JhbSBzaXRlIGRpZCBub3QgcnVuIHRoZSB3aG9sZSBwZWcgc29saXRhcmUgb2YgbWUgaHR0cDovL2UuLi5jb250ZW50LWF2YWlsYWJsZS10by1hdXRob3Itb25seS4uLmEub3JnL3dpa2kvUGVnX3NvbGl0YWlyZSBiZWNhdXVzZSBvZiB0aW1lIApsaW1pdCBleGNlZWQgdGhlcmVmb3JlIGkgdXNlZCBhIHNtYWxsIG8gc2hhcGVkIHN0cnVjdHVyZSBsaWtlIHRoaXMKCSAgICAgICAgICAgLiAgIC4gICAuICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICogICAqICAgKgogICAgICAgICAgIC4gICAqICAgKiAgIC4gICAqICAgKiAgIC4gIAogICAgICAgICAgIC4gICAqICAgLiAgIC4gICAuICAgKiAgIC4gCiAgICAgICAgICAgLiAgICogICAqICAgLiAgICogICAqICAgLgogICAgICAgICAgICAg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HRlbXBib2FyZFtpLGpdPScqJyB0aGVuCiAgICAgICAgICBiZWdpbgoJCQlpbmMoY291bnRlcik7CiAgICAgICAgICBlbmQ7CiAgICAgICAgZW5kOwogICAgICBlbmQ7CiAgICAgIGNvdW50Oj1jb3VudGVyOwogZW5kOwoKcHJvY2VkdXJlIHNob3cgKHRlbXBib2FyZCA6IHBlZ2JvYXJkKTsKIHZhcgogaSxqIDogaW50ZWdlcjsKIGJlZ2luCiAgZm9yIGk6PTEgdG8gNyBkbwogICAgICBiZWdpbgogICAgICAgIGZvciBqOj0xIHRvIDcgZG8KICAgICAgICBiZWdpbgogICAgICAgICAgV3JpdGUodGVtcGJvYXJkW2ksal0sJyAnKTsKICAgICAgICBlbmQ7CiAgICAgICAgV3JpdGVsbjsKICAgICAgZW5kOwogZW5kOwpmdW5jdGlvbiB0ZXN0VmFsaWQodGVtcHBlZ2JvYXJkOiBwZWdib2FyZCk6aW50ZWdlcjsKIHZhcgogZixrOmludGVnZXI7CiAgcm93MSxjb2wxLGksajppbnRlZ2VyOwoKICBiZWdpbgogICAgICAgZjo9MDsKICAgICAgIGZvciBpOj0xIHRvIDcgZG8KICAgICAgYmVnaW4KICAgICAgICBmb3Igajo9MSB0byA3IGRvCiAgICAgICAgYmVnaW4KICAgICAgICAgIGlmIHRlbXBwZWdib2FyZFtpLGpdPScqJyB0aGVuCiAgICAgICAgICBiZWdpbgogICAgICAgICAgICAgcm93MTo9IGk7CiAgICAgICAgICAgICBjb2wxOj0gajsKICAgICAgICAgICAgIGZvciBrOj0xIHRvIDQgZG8KICAgICAgICAgICAgIGJlZ2luCiAgICAgICAgICAgICAgcm93MTo9cm93MSttW2ssMV07CiAgICAgICAgICAgICAgY29sMTo9Y29sMSttW2ssMl07CiAgICAgICAgICAgICBpZigocm93MT4wKSBhbmQgKGNvbDEgPjApIGFuZCAocm93MTw4KSBhbmQgKGNvbDE8OCkpIHRoZW4KICAgICAgICAgICAgIGJlZ2luIAoKCQkJCQkgIGlmICgoa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Y29sLGRpcix0ZW1wYm9hcmQpOwogICAgICAgICBjb3VudGVyOj10ZXN0VmFsaWQodGVtcGJvYXJkKTsKCQkJaW5jKGkpOwoJCWVuZDsKCglwZWdzb2x2ZXI6PTA7CiAgZW5kOwoKCiAgdmFyCiAgICBwIDogcGVnYm9hcmQ9CiAgICAgICAgKCgnICcsJyAnLCcuJywnLicsJy4nLCcgJywnICcpLAogICAgICAgICAoJyAnLCcgJywnKicsJyonLCcqJywnICcsJyAnKSwKICAgICAgICAgKCcuJywnKicsJyonLCcuJywnKicsJyonLCcuJyksCiAgICAgICAgICgnLicsJyonLCcuJywnLicsJy4nLCcqJywnLicpLAogICAgICAgICAoJy4nLCcqJywnKicsJy4nLCcqJywnKicsJy4nKSwKICAgICAgICAgKCcgJywnICcsJyonLCcqJywnKicsJyAnLCcgJyksCiAgICAgICAgICgnICcsJyAnLCcuJywnLicsJy4nLCcgJywnICcpKTsKICB0ZW1wcGVnYm9hcmQgOiBwZWdib2FyZDsKICAgIHZhcgogaSxqICxyZSxyb3csY29sLGRpcjogaW50ZWdlcjsKICBiZWdpbgogICByb3c6PTE7CiAgIGNvbDo9MTsKICAgZGlyOj0xOwogZm9yIGk6PTEgdG8gNyBkbwogIGJlZ2luCiAgZm9yIGo6PTEgdG8gNyBkbwogICAgYmVnaW4KICAgIHRlbXBwZWdib2FyZFtpLGpdOj1wW2ksal07CiAgICBlbmQ7CiAgZW5kOwogICAgIHJlOj1wZWdzb2x2ZXIocm93LGNvbCxkaXIsdGVtcHBlZ2JvYXJkKTsKICAgICB3cml0ZWxuKCdzdGFydCBzb2x2aW5nLi4uJyk7CiAgICAgc2hvdyh0ZW1wcGVnYm9hcmQpOwogICAgIHdyaXRlbG4ocmUpOwogICAgIHJlYWRsbjsKIGVuZC4K