Jump to content

what functions...


blueman378

Recommended Posts

Hi giys.

 

im looking to make something which basically you can pass it a list of words one of the words would have been choosen (the list is generated already)

 

basically one of the words is the correct word, for each word you try you get the number of letters in the right place (eg 3/5)

 

so i would want to make a script which can solve these for me what sort of functions will i need to do this?

 

TRULY  1/5 correct

TRADE

GREED

PROOF

DRINK

TRIES

BRINK

THIEF

FREED

TRASH

SPIED

DRIED

BRICK

FREES

GREEN

CRIED

TRACE

GRIEF

 

now the word that is correct is dried.

 

you would find it using this method:

 

choose one word (I just choose the first)and use it.

 

Afterwards, cross off the word you selected.

Then, match the letters of the other words to your chosen word. If they have more or less letters in common than the number displayed (eg 2/5), cross them off. You should be left with a list of four or five words.

 

Repeat the process again but with a word thats not crossed off.

By this time, you should have one or two words left. Choose one of the words and use it. Then choose the other if it doesn't work.

 

so basically i want it to narrow the "guess" work down as low as possible

 

 

Link to comment
https://forums.phpfreaks.com/topic/136908-what-functions/
Share on other sites

Take a look at the functions for splitting a string down into an array of letter such as str_split(), and then the various array functions such as array_intersect() and array_intersect_assoc() that can be used for matching entries and their positions within a pair of arrays

Link to comment
https://forums.phpfreaks.com/topic/136908-what-functions/#findComment-715086
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.