tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
20
Task/Pangram-checker/PHP/pangram-checker.php
Normal file
20
Task/Pangram-checker/PHP/pangram-checker.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
function isPangram($text) {
|
||||
foreach (str_split($text) as $c) {
|
||||
if ($c >= 'a' && $c <= 'z')
|
||||
$bitset |= (1 << (ord($c) - ord('a')));
|
||||
else if ($c >= 'A' && $c <= 'Z')
|
||||
$bitset |= (1 << (ord($c) - ord('A')));
|
||||
}
|
||||
return $bitset == 0x3ffffff;
|
||||
}
|
||||
|
||||
$test = array(
|
||||
"the quick brown fox jumps over the lazy dog",
|
||||
"the quick brown fox jumped over the lazy dog",
|
||||
"ABCDEFGHIJKLMNOPQSTUVWXYZ",
|
||||
"ABCDEFGHIJKL.NOPQRSTUVWXYZ",
|
||||
"ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ"
|
||||
);
|
||||
|
||||
foreach ($test as $str)
|
||||
echo "$str : ", isPangram($str) ? 'T' : 'F', '</br>';
|
||||
Loading…
Add table
Add a link
Reference in a new issue