Programming Question - Combinations/Permutations
- Matt Vinyl
- Senior Member
- Posts: 7198
- Joined: Wed May 11, 2005 6:56 pm
- Location: Lost in the outback, Bryan
Yes, true - I may well cull my dictionary. Just import it into Access or something and do a bit of simple code to limit the list, then re-export it to txt.
Just reading through your code at the moment, and I think I should be alright converting it, may have to drop you a PM if I get stuck...
EWQ - input much appreciated and interesting too! I've always craved a mathematical mind!

Just reading through your code at the moment, and I think I should be alright converting it, may have to drop you a PM if I get stuck...

EWQ - input much appreciated and interesting too! I've always craved a mathematical mind!


"And do you ever contradict yourself, Minister?" "Well, yes and no..."
Minor tip, but it might be worth generating your words and inserting them into a sorted list, and only then doing the "real word" check by stepping through that list as you step through your dictionary. Then you know that the next word in the list will be after your current place in the dictionary. That should save you a fair few random accesses into your dictionary, as you know you won't have to go backwards. (Will also help with memory cacheing too).
(Not read the source, so apologies if that's what you're doing already
)
(Not read the source, so apologies if that's what you're doing already

-
- Senior Member
- Posts: 540
- Joined: Wed Jun 29, 2005 4:08 pm
- Location: Leedsish
- Contact:
You can still use one word list, it just needs to be sorted from lowest number of letters to highest number of letters instead of alphabetically.
You then just need to know at which line 8 letter words start and finish (or any other number(s)), and adjust the loop to search between those lines only..
You then just need to know at which line 8 letter words start and finish (or any other number(s)), and adjust the loop to search between those lines only..
New optimised version attatched.
Ive done away with a nested loop, and it also now only checks dictionary words between 3 and 8 letters.
Not as fast as I thought, but it is more than twice as fast as the origional.
Ive done away with a nested loop, and it also now only checks dictionary words between 3 and 8 letters.
Not as fast as I thought, but it is more than twice as fast as the origional.
- Attachments
-
- v2_139.zip
- (368.44 KiB) Downloaded 51 times
- Matt Vinyl
- Senior Member
- Posts: 7198
- Joined: Wed May 11, 2005 6:56 pm
- Location: Lost in the outback, Bryan
Ah, good stuff! Will take a look through this today! Hopefully, should have most of the game put together by the end of the coming week, so will upload a trial version here! 
Cheers for all your help!!
I just couldn't get my head around it at first! 


Cheers for all your help!!



"And do you ever contradict yourself, Minister?" "Well, yes and no..."
- Matt Vinyl
- Senior Member
- Posts: 7198
- Joined: Wed May 11, 2005 6:56 pm
- Location: Lost in the outback, Bryan
Looking at the dictionary I've used, there are a lot of words that I wouldn't say were 'commonly used'. For example, 'Recipes' throws up this many 3 letter words:
cep cis ers ice ire per pes pic pie pis psi rec rei rep res rip sec sei ser sic sip sir sri
I know that quite a few of these are common, but some are a lot less 'familiar'. Sei, anyone?
I now may add another limitation that says the chosen 8 letter word (I know I used a 7-letter word for my example!) will only be included if the number of 3-letter words is also limited (to say 8 or 10). I know this will still pick up words that do contain a lot of obscure smaller words, but hey, it'll make it interesting!

cep cis ers ice ire per pes pic pie pis psi rec rei rep res rip sec sei ser sic sip sir sri
I know that quite a few of these are common, but some are a lot less 'familiar'. Sei, anyone?
I now may add another limitation that says the chosen 8 letter word (I know I used a 7-letter word for my example!) will only be included if the number of 3-letter words is also limited (to say 8 or 10). I know this will still pick up words that do contain a lot of obscure smaller words, but hey, it'll make it interesting!


"And do you ever contradict yourself, Minister?" "Well, yes and no..."
-
- Senior Member
- Posts: 4166
- Joined: Wed Jul 20, 2005 3:33 pm
- Istenem
- Senior Member
- Posts: 5918
- Joined: Sat Apr 30, 2005 2:42 pm
- Location: the nation's capital
- Contact:
yuck!Matt Vinyl wrote: cep cis ers ice ire per pes pic pie pis psi rec rei rep res rip sec sei ser sic sip sir sri
you might want to winnow out dross like that Matt. (i realise it is probably a big job.)
a. it devalues the integrity of a word game if non-words are accepted. don't get me started on scrabble but that allows far too many combinations of letters to pass for words.
b. it makes the game easier for deadheads who can just thrash out random combinations of letters and get lucky.
c. it becomes a game of learning rather than quickwittedness/skill
just my 2pworth.
nobody ever wins on those things.
A few more for you
:
cep - An edible mushroom.
cis - Having two mutations on two genes on the same chromosome of a homologous pair.
ers - A vetch, grown in Europe for forage.
pes - A foot or footlike part. / The 17th letter of the Hebrew alphabet.
pis - The plural of Pi, the 16th letter of the Greek alphabet.
rei - A portuguese money of account, in value about one tenth of a cent.
sec - (of wines) Dry, not sweet.
sei - A sei whale.
ser - A unit of weight in India.
sri - A Hindu title of address prefixed to the name of a deity, holy person, etc.
I take your point about them reducing the skill required in a word game, particularly as regards to random button-bashing. But surely knowing lots of esoteric words is the point of being good at a word game? Yes, you should also know what the word means, and while that can be enforced on things like Countdown, it's harder to enforce on quiz boxes.
Maybe once you've entered a word you have to pic the meaning from a selection? I apperciate that there would still be a chance of randomly selecting the right answer, but no more than the average spoiler.

cep - An edible mushroom.
cis - Having two mutations on two genes on the same chromosome of a homologous pair.
ers - A vetch, grown in Europe for forage.
pes - A foot or footlike part. / The 17th letter of the Hebrew alphabet.
pis - The plural of Pi, the 16th letter of the Greek alphabet.
rei - A portuguese money of account, in value about one tenth of a cent.
sec - (of wines) Dry, not sweet.
sei - A sei whale.
ser - A unit of weight in India.
sri - A Hindu title of address prefixed to the name of a deity, holy person, etc.
I take your point about them reducing the skill required in a word game, particularly as regards to random button-bashing. But surely knowing lots of esoteric words is the point of being good at a word game? Yes, you should also know what the word means, and while that can be enforced on things like Countdown, it's harder to enforce on quiz boxes.
Maybe once you've entered a word you have to pic the meaning from a selection? I apperciate that there would still be a chance of randomly selecting the right answer, but no more than the average spoiler.
- Matt Vinyl
- Senior Member
- Posts: 7198
- Joined: Wed May 11, 2005 6:56 pm
- Location: Lost in the outback, Bryan
All good points! 
(Nice list Weyland!)
There are a few options, as suggested. I 'could' try and find a dictionary that is more limited. I 'could' allow the words to be used, but considerably limit the score of getting the three letter words. (Surely as I go up the 'letter scale' (4,5,6 etc.) the amount of non-words (that are included in the dictionary) would decrease?) (And how many brackets can I use in one sentence!?)
This has become far more involved that I thought it would!

(Nice list Weyland!)
There are a few options, as suggested. I 'could' try and find a dictionary that is more limited. I 'could' allow the words to be used, but considerably limit the score of getting the three letter words. (Surely as I go up the 'letter scale' (4,5,6 etc.) the amount of non-words (that are included in the dictionary) would decrease?) (And how many brackets can I use in one sentence!?)
This has become far more involved that I thought it would!

"And do you ever contradict yourself, Minister?" "Well, yes and no..."