Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.basic.misc

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 10-31-2009, 09:40 AM
Helge Haensel
Guest
 
Posts: n/a
Default Crossword puzzle


Hallo NG!
Still somebody watching this newsgroup?

I have a wordlist with some 180.000 entries, of course of different length
and not necessarily sorted. I create a pattern of characters like
'.EA...R'.
Now I am looking for a search algorithm that throws up 'WEATHER' but not
'THEATER' and so on.
This is a classical crossword puzzle issue and I assume it is already
solved.
Do you know a suitable/fast solution?
Thanks!

Vy 73! Helge
--
Helge, DJ1WM


Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 10-31-2009, 11:59 AM
Ralph
Guest
 
Posts: n/a
Default Re: Crossword puzzle


"Helge Haensel" <dj1wm@nurfuerspam.de> wrote in message
newsp.u2nuk7p2sjedh2@dj1wm.fqdn.th-h.de...
>
> Hallo NG!
> Still somebody watching this newsgroup?
>
> I have a wordlist with some 180.000 entries, of course of different length
> and not necessarily sorted. I create a pattern of characters like
> '.EA...R'.
> Now I am looking for a search algorithm that throws up 'WEATHER' but not
> 'THEATER' and so on.
> This is a classical crossword puzzle issue and I assume it is already
> solved.
> Do you know a suitable/fast solution?
> Thanks!
>


You might take a look at regular expressions.
Which library will depend on your OS, development platform, ...

-ralph


Reply With Quote
  #3 (permalink)  
Old 10-31-2009, 02:06 PM
Gordon Rahman
Guest
 
Posts: n/a
Default Re: Crossword puzzle

Do you mean like this? :

a$(1) = "coconut"
a$(2) = "american"
a$(3) = "weather"
a$(4) = "heater"
a$(5) = "theater"
a$(6) = "amphi-theater"

for t = 1 to 6
if instr(a$(t),"ea",2) = 2 and instr(a$(t),"e",6) = 6 then print a$(t)
next t

Gordon




"Helge Haensel" <dj1wm@nurfuerspam.de> wrote in message
newsp.u2nuk7p2sjedh2@dj1wm.fqdn.th-h.de...
>
> Hallo NG!
> Still somebody watching this newsgroup?
>
> I have a wordlist with some 180.000 entries, of course of different length
> and not necessarily sorted. I create a pattern of characters like
> '.EA...R'.
> Now I am looking for a search algorithm that throws up 'WEATHER' but not
> 'THEATER' and so on.
> This is a classical crossword puzzle issue and I assume it is already
> solved.
> Do you know a suitable/fast solution?
> Thanks!
>
> Vy 73! Helge
> --
> Helge, DJ1WM
>
>



Reply With Quote
  #4 (permalink)  
Old 10-31-2009, 06:57 PM
DMCC
Guest
 
Posts: n/a
Default Re: Crossword puzzle

On Oct 31, 10:40*am, "Helge Haensel" <dj...@nurfuerspam.de> wrote:
> Hallo NG!
> Still somebody watching this newsgroup?
>
> I have a wordlist with some 180.000 entries, of course of different length *
> and not necessarily sorted. I create a pattern of characters *like *
> '.EA...R'.
> Now I am looking for a search algorithm that throws up 'WEATHER' but not *
> 'THEATER' and so on.
> This is a classical crossword puzzle issue and I assume it is already *
> solved.
> Do you know a suitable/fast solution?
> Thanks!
>
> Vy 73! Helge
> --
> Helge, DJ1WM


grep does that:

user@unixbox:~$ grep '^.ea...r$' /usr/share/dict/words
Heather
Leander
Realtor
beadier
feather
headier
heather
heavier
leafier
leakier
learner
leather
mealier
meander
meatier
reactor
readier
realtor
seamier
teacher
tearier
wearier
weather


Reply With Quote
  #5 (permalink)  
Old 10-31-2009, 10:39 PM
news@rtrussell.co.uk
Guest
 
Posts: n/a
Default Re: Crossword puzzle

On Oct 31, 12:59*pm, "Ralph" <nt_consultin...@yahoo.com> wrote:
> You might take a look at regular expressions.
> Which library will depend on your OS, development platform, ...


A BBC BASIC solution using regular expressions is listed below.

Richard.
http://www.rtrussell.co.uk/
To reply by email change 'news' to my forename.

SYS "LoadLibrary", @lib$+"gnu_regex.dll" TO gnu_regex%
IF gnu_regex% = 0 ERROR 100, "Cannot load gnu_regex.dll"
SYS "GetProcAddress", gnu_regex%, "regcomp" TO `regcomp`
SYS "GetProcAddress", gnu_regex%, "regexec" TO `regexec`

DIM buffer% 255

pattern$ = "^.ea..e. "
SYS `regcomp`, buffer%, pattern$, 2 TO result%
IF result% ERROR 101, "Failed to compile regular expression"

sowpods% = OPENIN("C:\mydown~1\sowpods.txt")
REPEAT
INPUT #sowpods%, A$
IF ASC(A$) = 10 A$ = MID$(A$,2)
SYS `regexec`, buffer%, A$, 0, 0, 0 TO result%
IF result% = 0 PRINT A$
UNTIL EOF#sowpods%
CLOSE #sowpods%
Reply With Quote
  #6 (permalink)  
Old 10-31-2009, 11:04 PM
Gordon Rahman
Guest
 
Posts: n/a
Default Re: Crossword puzzle

Hello,

I watch this Newsgroup too.
Thougth it was about BASIC.
So here is my BASIC solution.
This may not be a fast solution, but it's BASIC.

while b$ <> "zzz"
b = b + 1
read b$
wend
restore

dim a$(b)

for t = 1 to b
read b$
a$(t) = b$
next t


data Heather,Leander,Realtor,beadier,feather,headier,he ather
data heavier,leafier,leakier,learner,realtor,seamier,te acher
data tearier,wearier,weather,coconut,american,theater," ampi-theater"
data zzz


input "first instring to look for ";f$
input "position of first instring ";pf
input "second instring to look for ";s$
input "position of second instring ";ps

for t = 1 to b
if instr(a$(t),f$,pf) = pf and instr(a$(t),s$,ps) = ps then
print a$(t)
end if
next t

print rint "done"
wait

'global items
'function found$(f$,pf,s$,ps)
'for t = 1 to items
'if instr(a$(t),f$,pf) = pf and instr(a$(t),s$,ps) = ps then
'found$ = a$(t)
'end if
'next t
'end function

Gordon



"Helge Haensel" <dj1wm@nurfuerspam.de> wrote in message
newsp.u2nuk7p2sjedh2@dj1wm.fqdn.th-h.de...
>
> Hallo NG!
> Still somebody watching this newsgroup?
>
> I have a wordlist with some 180.000 entries, of course of different length
> and not necessarily sorted. I create a pattern of characters like
> '.EA...R'.
> Now I am looking for a search algorithm that throws up 'WEATHER' but not
> 'THEATER' and so on.
> This is a classical crossword puzzle issue and I assume it is already
> solved.
> Do you know a suitable/fast solution?
> Thanks!
>
> Vy 73! Helge
> --
> Helge, DJ1WM
>
>



Reply With Quote
  #7 (permalink)  
Old 11-01-2009, 07:58 AM
Helge Haensel
Guest
 
Posts: n/a
Default Re: Crossword puzzle

Am 31.10.2009, 11:40 Uhr, schrieb Helge Haensel <dj1wm@nurfuerspam.de>:

>
> Hallo NG!
> Still somebody watching this newsgroup?
>
> I have a wordlist with some 180.000 entries, of course of different
> length and not necessarily sorted. I create a pattern of characters
> like '.EA...R'.
> Now I am looking for a search algorithm that throws up 'WEATHER' but not
> 'THEATER' and so on.
> This is a classical crossword puzzle issue and I assume it is already
> solved.
> Do you know a suitable/fast solution?
> Thanks!
>
> Vy 73! Helge


Hi, surprise!
Well, I was a little bit short with my search/find problem.
My system is: WindowsXP/HE/SP3, OfficeXP/Pro/SP3, VB5EE/SP3
Starting with the pattern as given above I need the possible fitting words
from the word list. 'WEATHER' or 'REALTOR' fits, 'BROTHER', 'WEATHERMAN'
don't fit.
Regular Expressions are a good idea, but I think I can't use them in VB5/6.
The solution of Gordon is a first step but not very flexible for an
extensive use.
Something like 'grep' would be optimal when using a linux/unix system and
being a keyboard hacker. The example code by Gordon isn't very flexible
because the pattern of course changes in length, in chars positions and so
in '.'-positions as a 'grep' would easily allow. But it is possibly the
only starting point to begin with.
Thanks so far.
Helge

Reply With Quote
  #8 (permalink)  
Old 11-01-2009, 09:19 AM
news@rtrussell.co.uk
Guest
 
Posts: n/a
Default Re: Crossword puzzle

On Nov 1, 8:58*am, "Helge Haensel" <dj...@nurfuerspam.de> wrote:
> Regular Expressions are a good idea, but I think I can't use them
> in VB5/6.


I'm pretty sure you can. If you can use 'gnu_regex.dll' in BBC BASIC
(see the example I posted) I'd be extremely surprised if you can't use
it in VB too. For details of where to download 'gnu_regex.dll' see
here:

http://bb4w.wikispaces.com/Using+regular+expressions

Richard.
http://www.rtrussell.co.uk/
To reply by email change 'news' to my forename.
Reply With Quote
  #9 (permalink)  
Old 11-01-2009, 10:02 AM
Helge Haensel
Guest
 
Posts: n/a
Default Re: Crossword puzzle

Am 01.11.2009, 11:19 Uhr, schrieb news@rtrussell.co.uk
<news@rtrussell.co.uk>:

> On Nov 1, 8:58 am, "Helge Haensel" <dj...@nurfuerspam.de> wrote:
>> Regular Expressions are a good idea, but I think I can't use them
>> in VB5/6.

>
> I'm pretty sure you can. If you can use 'gnu_regex.dll' in BBC BASIC
> (see the example I posted) I'd be extremely surprised if you can't use
> it in VB too. For details of where to download 'gnu_regex.dll' see
> here:
>
> http://bb4w.wikispaces.com/Using+regular+expressions
>
> Richard.
> http://www.rtrussell.co.uk/
> To reply by email change 'news' to my forename.


Hi, Richard.
Downloaded 'gnu_regex.exe' via the given link to my desktop.
After executing the exe I can't find it anywhere.
Searched for 'gnu_regex.dll'. OK?
Helge
Reply With Quote
  #10 (permalink)  
Old 11-01-2009, 10:17 AM
Gordon Rahman
Guest
 
Posts: n/a
Default Re: Crossword puzzle

Hallo Helge,

I will give it a try.
I'll make it flexible.

Someone (Derek) did that in QB already and published
the code in the ALT.LANG.BASIC Newsgroup. (15 september 2009)

I'm thinking of a different approach than Derek.
I'm back to the drawingboard.

Gordon.


"Helge Haensel" <dj1wm@nurfuerspam.de> wrote in message
newsp.u2nuk7p2sjedh2@dj1wm.fqdn.th-h.de...
>
> Hallo NG!
> Still somebody watching this newsgroup?
>
> I have a wordlist with some 180.000 entries, of course of different length
> and not necessarily sorted. I create a pattern of characters like
> '.EA...R'.
> Now I am looking for a search algorithm that throws up 'WEATHER' but not
> 'THEATER' and so on.
> This is a classical crossword puzzle issue and I assume it is already
> solved.
> Do you know a suitable/fast solution?
> Thanks!
>
> Vy 73! Helge
> --
> Helge, DJ1WM
>
>



Reply With Quote
  #11 (permalink)  
Old 11-01-2009, 11:29 AM
Helge Haensel
Guest
 
Posts: n/a
Default Re: Crossword puzzle

Am 01.11.2009, 12:17 Uhr, schrieb Gordon Rahman <grahman@planet.nl>:

> Hallo Helge,
>
> I will give it a try.
> I'll make it flexible.
>
> Someone (Derek) did that in QB already and published
> the code in the ALT.LANG.BASIC Newsgroup. (15 september 2009)
>
> I'm thinking of a different approach than Derek.
> I'm back to the drawingboard.
>
> Gordon.
>


Sorry about all that trouble. But now it becomes an interesting project.
BTW, all packers I have do not unpack that EXE! (downl'd from 'here' on
the linked page)
I'll check the ALB-Group via Google.
So long!
Helge
Reply With Quote
  #12 (permalink)  
Old 11-01-2009, 11:50 AM
Helge Haensel
Guest
 
Posts: n/a
Default Re: Crossword puzzle

Am 01.11.2009, 12:17 Uhr, schrieb Gordon Rahman <grahman@planet.nl>:

> Hallo Helge,
>
> I will give it a try.
> I'll make it flexible.
>
> Someone (Derek) did that in QB already and published
> the code in the ALT.LANG.BASIC Newsgroup. (15 september 2009)


Hi, actually 15.09.2008. Got it.
Helge

Reply With Quote
  #13 (permalink)  
Old 11-01-2009, 12:30 PM
Gordon Rahman
Guest
 
Posts: n/a
Default Re: Crossword puzzle

Here is my pattern recognition

'Pattern recognition meaning find ea and e and their relative pos

c$ = "...hello...ea...e." rint c$

for t = 1 to len(c$)
if mid$(c$,t,1)="." and mid$(c$,t+1,1)<>"." then gosub [dotEndFound]
if mid$(c$,t,1)<>"." and mid$(c$,t+1,1)="." then gosub [charEndFound]
next t

pf = s(1)+1
f$ = mid$(c$,pf,u(1)-s(1))
print "from ";pf,f$;" to ";u(1)

ps = s(2)+1
s$ = mid$(c$,ps,u(2)-s(2))
print "from ";ps,s$;" to ";u(2)

wait


[dotEndFound]
s1 = s1 + 1 :s(s1) = t
'print "start";s1;" at position ";s(s1) 't
return

[charEndFound]
s2 = s2 + 1 :u(s2) = t
'print "stop";s2;" at position ";u(s2) 't
return



'input "first instring to look for ";f$
'input "position of first instring ";pf
'input "second instring to look for ";s$
'input "position of second instring ";ps

Good luck,

Gordon



"Helge Haensel" <dj1wm@nurfuerspam.de> wrote in message
newsp.u2nuk7p2sjedh2@dj1wm.fqdn.th-h.de...
>
> Hallo NG!
> Still somebody watching this newsgroup?
>
> I have a wordlist with some 180.000 entries, of course of different length
> and not necessarily sorted. I create a pattern of characters like
> '.EA...R'.
> Now I am looking for a search algorithm that throws up 'WEATHER' but not
> 'THEATER' and so on.
> This is a classical crossword puzzle issue and I assume it is already
> solved.
> Do you know a suitable/fast solution?
> Thanks!
>
> Vy 73! Helge
> --
> Helge, DJ1WM
>
>



Reply With Quote
  #14 (permalink)  
Old 11-01-2009, 12:53 PM
news@rtrussell.co.uk
Guest
 
Posts: n/a
Default Re: Crossword puzzle

On Nov 1, 11:02*am, "Helge Haensel" <dj...@nurfuerspam.de> wrote:
> Downloaded 'gnu_regex.exe' via the given link to my desktop.
> After executing the exe I can't find it anywhere.


Looks like the file has become corrupted since I last downloaded it.
I've put the correct version here for you:

http://www.rtr.myzen.co.uk/gnu_regex.exe

Richard.
http://www.rtrussell.co.uk/
To reply by email change 'news' to my forename.
Reply With Quote
  #15 (permalink)  
Old 11-01-2009, 02:04 PM
Helge Haensel
Guest
 
Posts: n/a
Default Re: Crossword puzzle

Am 31.10.2009, 11:40 Uhr, schrieb Helge Haensel <dj1wm@nurfuerspam.de>:

>
> Hallo NG!
> Still somebody watching this newsgroup?
>
> I have a wordlist with some 180.000 entries, of course of different
> length and not necessarily sorted. I create a pattern of characters
> like '.EA...R'.
> Now I am looking for a search algorithm that throws up 'WEATHER' but not
> 'THEATER' and so on.
> This is a classical crossword puzzle issue and I assume it is already
> solved.
> Do you know a suitable/fast solution?
> Thanks!
>
> Vy 73! Helge


Well, I got Dereks code to run for me. I simplified it to my needs and it
finds the pattern (see above) within 2 seconds out of my wordlist with
178510 entries.
For Dereks code look here:
http://groups.google.com/group/alt.l...3db2c75758f0e3
Thanks to Derek, thanks to all of you!
Helge

The code of my main is as follows:

Sub main()
Let J = 1
hdl0 = FreeFile
Open "C:\Utilities\Kreuzwort\dist\files\wordlist.tx t" For Input As #hdl0
Do While Not EOF(hdl0)
M$ = "-1"
RE$ = "^.EA...R$"
Line Input #hdl0, Text$
If M$ = LTrim$(Str$(RegExp%(RE$, Text$))) Then Debug.Print "Okay"
Let J = J + 1
DoEvents
Loop
Debug.Print J
Close
End sub
Reply With Quote
 
Reply

Popular Tags in the Forum
crossword, puzzle

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 06:54 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.