Re: [GENERAL] Finding matching words in a word game

2013-03-06 Thread Alexander Farber
Thanks, will try that (the "dumb" approach) too :-) Still working on my dictionary (will be auto-generated by a script). On Wed, Mar 6, 2013 at 2:57 PM, Chris Angelico wrote: > words = {} > for word in dictionary: # provide a dictionary somehow - maybe from a > file/db > words.setdefault

Re: [GENERAL] Finding matching words in a word game

2013-03-06 Thread Chris Angelico
On Tue, Mar 5, 2013 at 8:29 PM, Alexander Farber wrote: > is there maybe a clever way of finding all possible words > from a given set of letters by means of PostgreSQL > (i.e. inside the database vs. scanning all database > rows by a PHP script, which would take too long) - > if the dictionary is

Re: [GENERAL] Finding matching words in a word game

2013-03-06 Thread Misa Simic
Hi, I think you can make another table: Word, letter, count (word, letter - pk) In good_words add column sorted_letters. Now we can make a view based on that two tables: Word, letter, count, sorted_letters Now we need two immutable functions: 1. For given word returns sorted_letters "word"

Re: [GENERAL] Finding matching words in a word game

2013-03-05 Thread Jeff Janes
On Tue, Mar 5, 2013 at 1:29 AM, Alexander Farber wrote: > Hello, > > is there maybe a clever way of finding all possible words > from a given set of letters by means of PostgreSQL > (i.e. inside the database vs. scanning all database > rows by a PHP script, which would take too long) - > if the d

Re: [GENERAL] Finding matching words in a word game

2013-03-05 Thread Alexander Farber
Or I could add integer columns 'a', 'b', ... ,'z' to the table On Tue, Mar 5, 2013 at 10:29 AM, Alexander Farber wrote: > > create table good_words ( > word varchar(16) primary key, > stamp timestamp default current_timestamp > ); > > http://stackoverflow.com/questions/15220072/po

[GENERAL] Finding matching words in a word game

2013-03-05 Thread Alexander Farber
Hello, is there maybe a clever way of finding all possible words from a given set of letters by means of PostgreSQL (i.e. inside the database vs. scanning all database rows by a PHP script, which would take too long) - if the dictionary is kept in a simple table like: create table good_words (