Note that there are some explanatory texts on larger screens.

plurals
  1. POAlgorithm Issue: letter combinations
    text
    copied!<p>I'm trying to write a piece of code that will do the following:</p> <p>Take the numbers 0 to 9 and assign one or more letters to this number. For example:</p> <pre><code>0 = N, 1 = L, 2 = T, 3 = D, 4 = R, 5 = V or F, 6 = B or P, 7 = Z, 8 = H or CH or J, 9 = G </code></pre> <p>When I have a code like 0123, it's an easy job to encode it. It will obviously make up the code NLTD. When a number like 5,6 or 8 is introduced, things get different. A number like 051 would result in more than one possibility:</p> <p>NVL and NFL</p> <p>It should be obvious that this gets even "worse" with longer numbers that include several digits like 5,6 or 8.</p> <p>Being pretty bad at mathematics, I have not yet been able to come up with a decent solution that will allow me to feed the program a bunch of numbers and have it spit out all the possible letter combinations. So I'd love some help with it, 'cause I can't seem to figure it out. Dug up some information about permutations and combinations, but no luck.</p> <p>Thanks for any suggestions/clues. The language I need to write the code in is PHP, but any general hints would be highly appreciated.</p> <h3>Update:</h3> <p>Some more background: (and thanks a lot for the quick responses!)</p> <p>The idea behind my question is to build a script that will help people to easily convert numbers they want to remember to words that are far more easily remembered. This is sometimes referred to as "pseudo-numerology".</p> <p>I want the script to give me all the possible combinations that are then held against a database of stripped words. These stripped words just come from a dictionary and have all the letters I mentioned in my question stripped out of them. That way, the number to be encoded can usually easily be related to a one or more database records. And when that happens, you end up with a list of words that you can use to remember the number you wanted to remember.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload