|
Post by bluatigro on Oct 15, 2018 12:31:07 GMT
error : some char's shoot be visable
dim q( 20 , 20 ) , a$( 20 , 20 ) global x.max , y.max x.max = 12 y.max = 10 y = 1 while r$ <> "=" read r$ for x = 1 to len( r$ ) a$( x , y ) = mid$( r$ , x , 1 ) next x y = y + 1 wend data "rtrnefrusttl" data "eeehcuodnrwe" data "sdskklimaate" data "tuetcgstrand" data "airhsyammves" data "ukviuitjesrl" data "rbestemminge" data "arremsireotr" data "niepaspoorte" data "tlneiksretaw" data "="
while w$ <> "=" read w$ ''horizontal for x = 1 to x.max - len( w$ ) for y = 1 to y.max call zoek x , y , w$ , 1 , 0 next y next x for x = len( w$ ) to x.max for y = 1 to y.max call zoek x , y , w$ , -1 , 0 next y next x ''vertical for x = 1 to x.max for y = 1 to y.max - len( w$ ) call zoek x , y , w$ , 0 , 1 next y next x for x = 1 to x.max for y = len( w$ ) to y.max call zoek x , y , w$ , 0 , -1 next y next x ''diagonal \ for x = 1 to x.max - len( w$ ) for y = 1 to y.max - len( w$ ) call zoek x , y , w$ , 1 , 1 next y next x for x = len( w$ ) to x.max for y = len( w$ ) to y.max call zoek x , y , w$ , -1 , -1 next y next x ''diagonal / for x = 1 to x.max - len( w$ ) for y = len( w$ ) to y.max call zoek x , y , w$ , 1 , -1 next y next x for x = len( w$ ) to x.max for y = 1 to y.max - len( w$ ) call zoek x , y , w$ , -1 , 1 next y next x
wend data "paspoort" data "bestemming" data "douce" data "klimaat" data "duikbril" data "reisgids" data "reserveren" data "restaurant" data "rontvaart" data "strand" data "surfen" data "ticet" data "toerisme" data "uitje" data "warmte" data "waterskien" data "werelddeel" data "=" for y = 1 to y.max for x = 1 to x.max if q( x , y ) then print "." ; else print a$( x , y ) ; end if next x print next y end sub zoek x , y , w$ , dx , dy d = 0 while mid$( w$ , d , 1 ) = a$( x + d * dx , y + d * dy ) _ and d < len( w$ ) d = d + 1 wend if d = len( w$ ) - 1 then for i = 0 to d q( x + i * dx , y + i * dy ) = 1 next i end if end sub
|
|
|
Post by tsh73 on Oct 15, 2018 19:31:33 GMT
in the sub zoek: letters in MID$ starts from 1 , so probably should be while mid$( w$ , d+1 , 1 ) = Condition while mid$( w$ , d , 1 ) = a$( x + d * dx , y + d * dy ) _ and d < len( w$ ) breaks then "d>=len( w$ )", so next condition probably should be without "-1" if d = len( w$ ) then Last one. You set q( x + i * dx , y + i * dy ) = 1 where letter is, but show letter where q(x,y) is 0: if q( x , y ) then print "." ; else print a$( x , y ) ; end if After that it does show something
|
|
|
Post by bluatigro on Oct 16, 2018 11:00:17 GMT
update : code sugestions added
error : 'restaurant' a vertical word is not fount there may be others
dim q( 20 , 20 ) , a$( 20 , 20 ) global x.max , y.max x.max = 12 y.max = 10 y = 1 while r$ <> "=" read r$ for x = 1 to len( r$ ) a$( x , y ) = mid$( r$ , x , 1 ) next x y = y + 1 wend data "rtrnefrusttl" data "eeehcuodnrwe" data "sdskklimaate" data "tuetcgstrand" data "airhsyammves" data "ukviuitjesrl" data "rbestemminge" data "arremsireotr" data "niepaspoorte" data "tlneiksretaw" data "="
while w$ <> "=" read w$ ''horizontal - for x = 1 to x.max - len( w$ ) for y = 1 to y.max call zoek x , y , w$ , 1 , 0 next y next x for x = len( w$ ) to x.max for y = 1 to y.max call zoek x , y , w$ , -1 , 0 next y next x ''vertical | for x = 1 to x.max for y = 1 to y.max - len( w$ ) call zoek x , y , w$ , 0 , 1 next y next x for x = 1 to x.max for y = len( w$ ) to y.max call zoek x , y , w$ , 0 , -1 next y next x ''diagonal \ for x = 1 to x.max - len( w$ ) for y = 1 to y.max - len( w$ ) call zoek x , y , w$ , 1 , 1 next y next x for x = len( w$ ) to x.max for y = len( w$ ) to y.max call zoek x , y , w$ , -1 , -1 next y next x ''diagonal / for x = 1 to x.max - len( w$ ) for y = len( w$ ) to y.max call zoek x , y , w$ , 1 , -1 next y next x for x = len( w$ ) to x.max for y = 1 to y.max - len( w$ ) call zoek x , y , w$ , -1 , 1 next y next x
wend data "paspoort" data "bestemming" data "douce" data "klimaat" data "duikbril" data "reisgids" data "reserveren" data "restaurant" data "rontvaart" data "strand" data "surfen" data "ticet" data "toerisme" data "uitje" data "warmte" data "waterskien" data "werelddeel" data "=" for y = 1 to y.max for x = 1 to x.max if q( x , y ) then print "." ; else print a$( x , y ) ; end if next x print next y end sub zoek x , y , w$ , dx , dy d = 0 while mid$( w$ , d + 1 , 1 ) = a$( x + d * dx , y + d * dy ) _ and d < len( w$ ) d = d + 1 wend if d = len( w$ ) then for i = 0 to d q( x + i * dx , y + i * dy ) = 1 next i end if end sub
|
|
|
Post by tsh73 on Oct 16, 2018 12:42:12 GMT
re:
len("restaurant") is 10 y.max = 10
so
for y = 1 to y.max - len( w$ ) goes from 1 to 0 - no iterations.
Should be
for y = 1 to y.max - len( w$ )+1
(something like this could happen over other directions?)
|
|
|
Post by bluatigro on Oct 17, 2018 10:50:56 GMT
@ tsh73 : pluged your sugestion in
the solution has to many char's
dim q( 20 , 20 ) , a$( 20 , 20 ) global x.max , y.max x.max = 12 y.max = 10 y = 1 while r$ <> "=" read r$ for x = 1 to len( r$ ) a$( x , y ) = mid$( r$ , x , 1 ) next x y = y + 1 wend data "rtrnefrusttl" data "eeehcuodnrwe" data "sdskklimaate" data "tuetcgstrand" data "airhsyammves" data "ukviuitjesrl" data "rbestemminge" data "arremsireotr" data "niepaspoorte" data "tlneiksretaw" data "="
while w$ <> "=" read w$ ''horizontal - for x = 1 to x.max - len( w$ ) + 1 for y = 1 to y.max call zoek x , y , w$ , 1 , 0 next y next x for x = len( w$ ) + 1 to x.max for y = 1 to y.max call zoek x , y , w$ , -1 , 0 next y next x ''vertical | for x = 1 to x.max for y = 1 to y.max - len( w$ ) + 1 call zoek x , y , w$ , 0 , 1 next y next x for x = 1 to x.max for y = len( w$ ) + 1 to y.max call zoek x , y , w$ , 0 , -1 next y next x ''diagonal \ for x = 1 to x.max - len( w$ ) + 1 for y = 1 to y.max - len( w$ ) + 1 call zoek x , y , w$ , 1 , 1 next y next x for x = len( w$ ) + 1 to x.max for y = len( w$ ) + 1 to y.max call zoek x , y , w$ , -1 , -1 next y next x ''diagonal / for x = 1 to x.max - len( w$ ) + 1 for y = len( w$ ) + 1 to y.max call zoek x , y , w$ , 1 , -1 next y next x for x = len( w$ ) + 1 to x.max for y = 1 to y.max - len( w$ ) + 1 call zoek x , y , w$ , -1 , 1 next y next x
wend data "paspoort" data "bestemming" data "douce" data "klimaat" data "duikbril" data "reisgids" data "reserveren" data "restaurant" data "rontvaart" data "strand" data "surfen" data "ticet" data "toerisme" data "uitje" data "warmte" data "waterskien" data "werelddeel" data "=" for y = 1 to y.max for x = 1 to x.max if q( x , y ) then print "." ; else print a$( x , y ) ; end if next x print next y for y = 1 to y.max for x = 1 to x.max if not( q( x , y ) ) then print a$( x , y ) ; end if next x next y print print "[ game over ]" end sub zoek x , y , w$ , dx , dy d = 0 while mid$( w$ , d + 1 , 1 ) = a$( x + d * dx , y + d * dy ) _ and d < len( w$ ) d = d + 1 wend if d = len( w$ ) then for i = 0 to d q( x + i * dx , y + i * dy ) = 1 next i end if end sub
|
|
|
Post by B+ on Oct 18, 2018 3:12:48 GMT
4 words are missing from your list. I found 3 and fixed the missing letter but have no idea where ticet was supposed to be. ' Word Search bluatigro puzzle 'from Word Search 2.txt for JB [B+=MGA] 2016-11-24
' http://justbasiccom.proboards.com/thread/152/word-charsquare-pulze-sovle ' 12 across 10 down data "rtrnefrusttl" data "eeeecuodnrwe" data "sdskklimaate" data "tuetcgstrand" data "airhsyammved" data "ukviuitjetrl" data "rbestemminge" data "arremsireotr" data "niepaspoorte" data "tlneiksretaw"
' 17 words to find data "paspoort" data "bestemming" data "douce" data "klimaat" data "duikbril" data "reisgids" data "reserveren" data "restaurant" data "rontvaart" data "strand" data "surfen" data "ticet" data "toerisme" data "uitje" data "warmte" data "waterskien" data "werelddeel"
global rows, cols 'for square block of letters xy is one side of square rows = 10 : cols = 12 : nWords = 17 : wpl = 1 'words per line dim L$(cols, rows), W$(nWords) DX(1) = 1 : DY(1) = 0 DX(2) = 1 : DY(2) = 1 DX(3) = 0 : DY(3) = 1 DX(4) = -1 : DY(4) = 1 DX(5) = -1 : DY(5) = 0 DX(6) = -1 : DY(6) = -1 DX(7) = 0 : DY(7) = -1 DX(8) = 1 : DY(8) = -1
for y = 1 to rows 'read in block of letters read r$ for x = 1 to cols L$(x, y) = mid$(r$, x, 1) next next call showPuzzle
for i = 1 to nWords/wpl 'read in list of words to find read r$ for j = 1 to wpl W$( (i - 1) * wpl + j ) = word$(r$, j) next next for i = 1 to nWords 'words not more than 12 letters? locate 2 * cols + 6 + (i-1) mod 2 * 17, int(i/2) + i mod 2 print i;" ";W$(i) next
for i = 1 to nWords 'this time through find word, show word, star word locate 1, rows + 5 : print space$(40) locate 1, rows + 5 : print W$(i); :input " press enter to show ";wayt call clearPuzzle if showWord(W$(i)) then locate 2 * cols + 6 + (i-1) mod 2 * 17, int(i/2) + i mod 2 print i;" ";W$(i);"*"; end if locate 1, rows + 5 : print space$(40) locate 1, rows + 5 : print W$(i); :input " OK, press enter ";wayt call showPuzzle next locate 10, rows + 7 : print "That's All Folks!"
sub showPuzzle locate 1, 1 for y = 1 to rows for x = 1 to cols print L$(x, y);" "; next print ">";chr$(96 + y) next locate 1, rows + 1 for x = 1 to cols : print "V "; : next locate 1, rows + 2 for x = 1 to cols : print chr$(96 + x);" "; : next print end sub
sub clearPuzzle for y = 1 to rows locate 0, y print space$(2 * cols) next end sub
function showWord(find$) 'first find a letter that matches the first 'then at that x,y try each of 8 directions to see if find a match 'be smart see if enough room to fit the find word before heading out 'if find it print in upper left board section 0, 0 first$ = mid$(find$, 1, 1) : lf1 = len(find$) - 1 for y = 1 to rows for x = 1 to cols if L$(x,y) = first$ then for d = 1 to 8 b1 = lf1 * DX(d) + x > 0 and lf1 * DX(d) + x <= cols b2 = lf1 * DY(d) + y > 0 and lf1 * DY(d) + y <= rows if b1 and b2 then b$ = first$ : xx = x + DX(d) : yy = y + DY(d) for i = 2 to len(find$) b$ = b$ + L$(xx, yy) xx = xx + DX(d) : yy = yy + DY(d) next if b$ = find$ then 'show our result for i = 1 to len(find$) locate 2*x-1, y : print L$(x,y); x = x + DX(d) : y = y + DY(d) next showWord = 1 : exit function end if end if next end if next next 'if still here, couldn't find find$ showWord = 0 end function
E.G. You need a double d in the last column to find the last word.
|
|