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
CDGKO
CDGLM
CDGLN
CDGLO
CDHJM
CDHJN
CDHJO
CDHKM
CDHKN
CDHKO
CDHLM
CDHLN
CDHLO
CDIJM
CDIJN
CDIJO
CDIKM
CDIKN
CDIKO
CDILM
CDILN
CDILO
CEGJM
CEGJN
CEGJO
CEGKM
CEGKN
CEGKO
CEGLM
CEGLN
CEGLO
CEHJM
CEHJN
CEHJO
CEHKM
CEHKN
CEHKO
CEHLM
CEHLN
CEHLO
CEIJM
CEIJN
CEIJO
CEIKM
CEIKN
CEIKO
CEILM
CEILN
CEILO
CFGJM
CFGJN
CFGJO
CFGKM
CFGKN
CFGKO
CFGLM
CFGLN
CFGLO
CFHJM
CFHJN
CFHJO
CFHKM
CFHKN
CFHKO
CFHLM
CFHLN
CFHLO
CFIJM
CFIJN
CFIJO
CFIKM
CFIKN
CFIKO
CFILM
CFILN
CFILO

Code :
//VGR07052003 Création par portage de source Turbo-Pascal
//
// ----- Functions
function Recursion($par,$prev,&$resu,&$nb) {
  // algorithm :
  // if length>0 treat first char in a loop, call for the rest
  // else memorize result and get out recursively
  if (strlen($par)>0) {
    switch ($par[0]) {
      case 0 : $chars=array('0'); break;
      case 1 : $chars=array('1'); break;
      case 2 : $chars=array('A','B','C'); break;
      case 3 : $chars=array('D','E','F'); break;
      case 4 : $chars=array('G','H','I'); break; // 'I' should be out (confusion with 1)
      case 5 : $chars=array('J','K','L'); break;
      case 6 : $chars=array('M','N','O'); break; // 'O' should be out (confusion with 0)
      case 7 : $chars=array('P','Q','R','S'); break;
      case 8 : $chars=array('T','U','V'); break;
      case 9 : $chars=array('W','X','Y','Z'); break;
    } // switch/case of
    foreach($chars as $char) { $newst=$prev.$char; Recursion(substr($par,1),$newst,$resu,$nb); }
  } else { // result found
    $resu[$nb]=$prev; // substr($resu[$nb-1],0,strlen($resu[$nb-1])-1);
    $nb++;
  }
} // Recursion Procedure

function DoIt($tel) {
  $resu=array();
  $nb=0;
  Recursion($tel,"",$resu,$nb);
  return $resu;
} // DoIt Array Function

// ----- MAIN
$numtel='23456';
$result=DoIt($numtel); // $result initialized in DoIt()
$nbres=count($result);
echo "number $numtel<BR>";
echo "$nbres combinations : <BR>";
for ($i=0;$i<$nbres;$i++) echo $result[$i].'<br>';

9. Conclusion top

FR

Ce code, bien que moins élégant que son original en Pascal, est encore plus élégant que la version C++ (comme d'habitude...) que vous trouverez à http://www.dreamincode.net/forums/showtopic50805.htm from zoom2ashish (Ashish Patel ) "Converting Telephone Numbers To Letters With All Combinations" on 21 Apr, 2009 - 12:25 PM for a 2 May, 2008 question.

Remarque importante : apparemment, malgré l'usage de cette technique depuis octobre 1912 (du moins en France, "Gutemberg 1225" ou le fameux "ODEon 84.00"), quelqu'un(*) a osé tenter de déposer un brevet en 1999 !!! ((WO/2001/011849) CODING TELEPHONE NUMBERS AND CIPHERS WITH LETTERS)
Je suis certain que mettre MON code de 1983 dans le domaine public n'enfreint aucun brevet ni marque déposée ;-))
(54) Title (EN): CODING TELEPHONE NUMBERS AND CIPHERS WITH LETTERS
(54) Title (FR): CODAGE DE NUMEROS DE TELEPHONE ET DE CHIFFRES AVEC DES LETTRES
(*) des Chinois partiellement établis en France, un comble.

Aux E.U.A. cet usage est apparu à la fin des 70s à l'arrivée des "1-800-FLOWERS" et autres "Telephone mnemonics" ou "vanity numbers").

Bien sûr, ce code ne trouve pas des ***mots*** : il crache simplement les combinaisons possibles : à vous d'en tirer des mots ;-)

Cordialement,

EN

Althought uglier than the original Pascal version, this PHP code fragment is more elegant (as usual ;-) than the C++ version that you may find at http://www.dreamincode.net/forums/showtopic50805.htm from zoom2ashish (Ashish Patel ) "Converting Telephone Numbers To Letters With All Combinations" on 21 Apr, 2009 - 12:25 PM for a 2 May, 2008 question.

Important Caveat : apparently, despite the use of this since October 1912 (at least in France, "Gutemberg 1225" or "ODEon 84.00"), someone(*) dared to try to depose a patent on a similar technique ! ((WO/2001/011849) CODING TELEPHONE NUMBERS AND CIPHERS WITH LETTERS) on 04/10/1999.
My code being from 1983, I think I don't infringe any patent showing it to the general public ;-)))
(54) Title (EN): CODING TELEPHONE NUMBERS AND CIPHERS WITH LETTERS
(54) Title (FR): CODAGE DE NUMEROS DE TELEPHONE ET DE CHIFFRES AVEC DES LETTRES
(*) des Chinois partiellement établis en France, un comble.

The use in the U.S.A. seems to date from the appearance of the 800- numbers in the late 1970's ("1-800-FLOWERS", so-called "Telephone mnemonics" or "vanity numbers"). You may read http://findarticles.com/p/articles/mi_qa3736/is_199901/ai_n8847105/

Of course, this code doesn't search for ***words*** in a dictionary ; it simply spits out the ***combinations*** : it's up to you to get words out of it ;-)

Best regards,

Vincent Graux (VGR) for European Experts Exchange and Edaìn Works  back to list of test scripts
Last update 2022-01-23 11:51:05