codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php $words = 'these are the words'; $words = explode(' ',$words); $rack = 'a b c d e f g'; $rack = explode(' ',$rack); $rack = array_flip($rack); $score = array("a" => 1, "b" => 1, "c" => 1, "d" => 1, "e" => 1, "f" => 1, "g" => 1, "h" => 1, "i" => 1, "j" => 1, "k" => 1, "l" => 1, "m" => 1, "n" => 1, "o" => 1, "p" => 1, "q" => 1, "r" => 1, "s" => 1, "t" => 1, "u" => 1, "v" => 1, "w" => 1, "x" => 1, "y" => 1, "z" => 1); $playable = array(); $playable_score = array(); foreach($words as $val) { $len = strlen($val); $thisscore = 0; for($run=0; $run<$len; $run++) { if (isset($rack[$val[$run]]) && isset($score[$val[$run]])) $thisscore+=$score[$val[$run]]; } if ($thisscore>0) { $playable[]=$val; $playable_score[]=$thisscore; } } print_r($playable); print_r($playable_score); ?>
Private
[
?
]
Run code
Submit