Re: Re: Anagram Type Puzzle
| From: | nayco | Date: | Mon, 10 Sep 2001 09:59:22 +0000 |
| Subject: | Re: Re: Anagram Type Puzzle | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-66712@lists.php.net to get a copy of this message | ||
Sorry, my F**** outlook replaced '//' commentaries by 'file://' ... these
lines where for debugging, they can be deleted !!!
----- Original Message -----
From: nicolas costes <nayco@club-internet.fr>
To: <php-general@lists.php.net>
Sent: Monday, September 10, 2001 11:36 AM
Subject: Re: [PHP] Re: [PHP-DEV] Anagram Type Puzzle
> <html>
> <body>
> <?php
>
>
> $tab=array("a"=>26,"b"=>25,"c"=>24,"d"=>23,
>
> "e"=>22,"f"=>21,"g"=>20,"h"=>19,
>
> "i"=>18,"j"=>17,"k"=>16,"l"=>15,
>
> "m"=>14,"n"=>13,"o"=>12,"p"=>11,
>
> "q"=>10,"r"=>9,"s"=>8,"t"=>7,
>
> "u"=>6,"v"=>5,"w"=>4,"x"=>3,
> "y"=>2,"z"=>1);
>
>
> $fid=fopen("testfile.txt","r");
>
> $line_num=0;
> while (!feof($fid))
> {
> $line_num++;
> file://echo "ligne : $line_num\n<br>\n";
> $line = strtolower(fgets($fid,4096));
> file://echo "contenu de la ligne : $line\n<br>\n";
> $words= explode(" ",$line);
> while (list($foo,$word)=each($words))
> {
> $word_value=0;
> for ($car=0;$car<strlen($word);$car++)
> {
> file://echo "lettre : $word[$car] - \t";
> if ($letter_value=$tab[$word[$car]])
> $word_value+=$letter_value;
> }
> file://echo "mot : $word; ";
> file://echo "valeur : $word_value\n<br>\n";
> if ($word_value==100)
> echo "the word <b>$word</b> on line $line_value of
> the input file has a value of $word_value.<br>\n";
> }
> }
> echo "<br>\n<font color=\"red\">If nothing appears above, no
> word
with
> a value of 100 was found !!!\n";
>
> ?>
> </body>
> </html>
>
>
> (°- Nayco,
> //\ Nayco@netcourrier.com
> v_/_ http://nayco.free.fr
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>