>>129 HSP
#module
#defcfunc is_match array field, int x, int y, int c
if y<0 or y>=length(field) : return 0
if x<0 or x>=strlen(field.y) : return 0
return peek(field.y, x)=c
#deffunc f129 array field, var word, local found_count
vx= 1, 1, 0,-1,-1,-1, 0, 1
vy= 0,-1,-1,-1, 0, 1, 1, 1
for sy, 0, length(field)
for sx, 0, strlen(field.cnt)
for d, 0, 8
is_found=1
x=sx : y=sy
repeat strlen(word)
if is_match(field, x, y, peek(word, cnt))=0 : is_found=0 : break
x+=vx.d : y+=vy.d
loop
if is_found : mes strf("%s %d,%d", word, sx+1, sy+1) : found_count++
next
next
next
if found_count=0 : mes strf("%s not found.", word)
return
#global

field="WVERTICALL","ROOAFFLSAB","ACRILIATOA","NDODKONWDC","DRKESOODDK","OEEPZEGLIW","MSIIHOAERA","ALRKRRIRER","KODIDEDRCD","HELWSLEUTH"
words="WEEK","FIND","RANDOM","SLEUTH","BACKWARD","VERTICAL","DIAGONAL","WIKIPEDIA","HORIZONTAL","WORDSEARCH"

foreach words
f129 field, words.cnt
loop