Help uberfish get extra credit!
only_samurai wrote: just because im a code whore… its now down to 5 lines of php code.
only_samurai linked me to this and challenged my php-manhood, so I stepped up and now have a single line of PHP code to do this.
Required: A text file (wordlist.txt) with each word on a new line. Capitalization, non-alpha characters are automatically removed. This of course can be fixed without haivng to add a new line (regex ftw).
markupforeach( explode("\n",file_get_contents("wordlist.txt")) as $word ) if( array_sum(array_map('ord',str_split(preg_replace('/[^a-zA-Z]?/i','',strtolower($word)))))-(96*strlen(preg_replace('/[^a-zA-Z]?/i','',strtolower($word)))) == 100 ) echo $word;
Basically I use file_get_contents to load entire file into a string, explode on /n, then have an if statement where I lowercase the string, remove non alpha characters, split the string (into an array of characters), run array_map() using ord() as my callback (ord converts a character to its ASCII value), run array_sum() to total up the array, then subtract 96 (lowercase 'a' is 97 in ASCII) times the length of the lowercased, non-alpha stripped string (the same string we split earlier). The if statement compares that to 100 and if true, we echo our word.
More can be done on the echo statement to remove window's trailing /r and formatting issues, but mreh I've proved my fu.