Post by bluatigro on Feb 23, 2021 15:07:23 GMT
i need help by this
a tectonic is a rect whit squares .
some squares have a number
the rect is divided in sets .
a set has 1 ... 5 squares .
etch square has to have a number
a set whit 1 square has number 1
a set whit 5 squares has numbers 1 ... 5
etc...
see runing code for example
error :
this code does not solve it jet
a tectonic is a rect whit squares .
some squares have a number
the rect is divided in sets .
a set has 1 ... 5 squares .
etch square has to have a number
a set whit 1 square has number 1
a set whit 5 squares has numbers 1 ... 5
etc...
see runing code for example
error :
this code does not solve it jet
global maxx , maxy , letter$
maxx = 3
maxy = 4
dim nr( maxx , maxy )''cel number
dim m$( maxx , maxy )''remaining numbers
dim a$( maxx + 1 , maxy + 1 )''belongs to set
for y = 0 to maxy
for x = 0 to maxx
read q$
nr(x,y) = val(word$(q$,1))
m$(x,y) = word$(q$,2)
a$(x,y) = word$(q$,3)
next x
next y
letter$ = "abcde"
data "0 1234 a","0 1234 a","0 12345 b","0 12345 b"
data "3 3 a","0 1234 a","0 12345 b","5 5 b"
data "0 12345 c","0 12345 c","3 3 d","2 2 b"
data "5 5 c","0 12345 c","0 12345 d","0 12345 d"
data "0 12345 c","0 1 e","0 12345 d","4 4 d"
[nieuw]
call show
input "[ press return ]" ; in$
call scan.for.solo
call show
input "[ press return ]" ; in$
call remove.rond.all
call show
input "[ press return ]" ; in$
call remove.number.of.set.all
call show
input "[ again ? [ y | n ] ]" ; in$
if in$ = "y" then goto [nieuw]
print "[ game over ]"
end
sub remove.number.of.set.all
print "remove number set all ."
for i = 1 to len(letter$)
q$ = ""
''scan for set
for x = 0 to maxx
for y = 0 to maxy
if mid$(letter$,i,1)=a$(x,y) then
if len(m$(x,y))>1 then
q$=q$+str$(x)+","+str$(y)+","+str$(nr(x,y))+" "
end if
end if
next y
next x
j = 1
while word$(q$,j)<>""
w$ = word$(q$,j)
x=val(word$(w$,1,","))
y=val(word$(w$,2,",") )
no=val(word$(w$,3,","))
call remove x , y , no
j = j + 1
wend
next i
end sub
sub scan.for.solo
print "scan for solo ."
for x = 0 to maxx
for y = 0 to maxy
if len(m$(x,y))=1 then
nr(x,y)=val(m$(x,y))
end if
next y
next x
end sub
sub remove.rond.all
print "remove rond all ."
for x = 0 to maxx
for y = 0 to maxy
call remove.rond x , y
next y
next x
end sub
sub remove.rond x , y
if len(m$(x,y)) > 1 then exit sub
no = val( m$(x,y) )
if save(x+1,y+1) then call remove x+1 , y+1 , no
if save(x+1,y) then call remove x+1 , y , no
if save(x+1,y-1) then call remove x+1 , y-1 , no
if save(x,y-1) then call remove x , y-1 , no
if save(x-1,y-1) then call remove x-1 , y-1 , no
if save(x-1,y) then call remove x-1 , y , no
if save(x-1,y+1) then call remove x-1 , y+1 , no
if save(x,y+1) then call remove x , y+1 , no
end sub
function save(x,y)
uit = 1
if x < 0 or x > maxx then uit = 0
if y < 0 or y > maxy then uit = 0
save = uit
end function
sub remove x , y , no
uit$ = ""
for i = 1 to len(m$(x,y))
if val(mid$(m$(x,y),i,1))<> no then
uit$ = uit$ + str$(no)
end if
next i
m$(x,y)=uit$
end sub
sub show
print "+-+-+-+-+"
for y = 0 to maxy
call showry y
print
for x = 0 to maxx
if a$(x,y)<>a$(x,y+1) then
print "+-" ;
else
print "+ " ;
end if
next x
print "+"
next y
end sub
sub showry y
print "|" ;
for x = 0 to maxx
call showcel x , y
if a$(x,y)<>a$(x+1,y) then
print "|" ;
else
print " " ;
end if
next x
end sub
sub showcel x , y
if nr(x,y)=0 then
print " " ;
else
print nr(x,y) ;
end if
end sub