Post by bluatigro on Sept 28, 2018 11:11:43 GMT
this is not jet ready
it does not solve the puzle complete
it does not solve the puzle complete
'' bluatigro 28 sept 2018
'' binary puzle solver try
'' there are only 0's and 1's
'' every row / colom has equal number of 0's and 1's
'' there are no more then 2 0's or 1's in a set
global max.x , max.y
max.x = 7
max.y = 7
dim p( max.x + 1 , max.y + 1 )
y = 0
while q$ <> "="
read q$
for x = 1 to len( q$ )
select case mid$( q$ , x , 1 )
case "0"
p( x - 1 , y ) = 0
case "1"
p( x - 1 , y ) = 1
case else
p( x - 1 , y ) = -1
end select
next x
y = y + 1
wend
data "1.0....."
data ".....0.."
data "....1..1"
data ".11....."
data "0......."
data "....0..1"
data "..00...1"
data ".1....1."
data "="
[verder]
call drawpuzle
call horizontal.lines
call vertical.lines
input "solved ? [ y / n ] : " ; in$
if in$ = "n" then goto [verder]
end
sub horizontal.lines
fl = 0
for y = 0 to max.y
for x = 0 to max.x
if p( x , y ) = -1 then
if save.x( x + 2 ) then
if p( x + 1 , y ) = p( x + 2 , y ) then
if p( x + 1 , y ) <> -1 then
print "horizontal " ; x ; " " ; y ; " before fount ."
fl = 1
if p( x + 1 , y ) = 0 then
p( x , y ) = 1
else
p( x , y ) = 0
end if
end if
end if
end if
if save.x( x - 2 ) then
if p( x - 1 , y ) = p( x - 2 , y ) then
if p( x - 1 , y ) <> -1 then
print "horizontal " ; x ; " " ; y ; " after fount ."
if p( x - 1 , y ) = 0 then
p( x , y ) = 1
else
p( x , y ) = 0
end if
end if
end if
end if
if save.x( x - 1 ) and save.x( x + 1 ) then
if p( x - 1 , y ) = p( x + 1 , y ) then
if p( x - 1 , y ) <> -1 then
print "horizontal " ; x ; " " ; y ; " between fount ."
if p( x - 1 , y ) = 0 then
p( x , y ) = 1
else
p( x , y ) = 0
end if
end if
end if
end if
end if
next x
next y
end sub
sub vertical.lines
for x = 0 to max.x
for y = 0 to max.y
if p( x , y ) = -1 then
if save.y( y + 2 ) then
if p( x , y + 1 ) = p( x , y + 2 ) then
if p( x , y + 1 ) <> -1 then
print "vertical " ; x ; " " ; y ; " above fount ."
fl = 1
if p( x , y + 1 ) = 0 then
p( x , y ) = 1
else
p( x , y ) = 0
end if
end if
end if
end if
if save.y( y - 2 ) then
if p( x , y - 1 ) = p( x , y - 2 ) then
if p( x , y - 1 ) <> -1 then
print "vertical " ; x ; " " ; y ; " below fount ."
fl = 1
if p( x , y + 1 ) = 0 then
p( x , y ) = 1
else
p( x , y ) = 0
end if
end if
end if
end if
if save.y( y - 1 ) and save.y( y + 1 ) then
if p( x , y - 1 ) = p( x , y + 1) then
if p( x , y - 1 ) <> -1 then
print "vertical " ; x ; " " ; y ; " between fount ."
if p( x , y - 1 ) = 0 then
p( x , y ) = 1
else
p( x , y ) = 0
end if
end if
end if
end if
end if
next y
next x
end sub
sub drawpuzle
tel = 0
for y = 0 to max.y
for x = 0 to max.x
print " " ;
select case p( x , y )
case 0
print "0" ;
case 1
print "1" ;
case else
print "." ;
tel = tel + 1
end select
next x
print
next y
if tel = 0 then
print "[ solved ]"
end
end if
end sub
function save.x( q )
save.x = 0 <= q and q <= max.x
end function
function save.y( q )
save.y = 0 <= q and q <= max.y
end function