mirror of
https://github.com/mx42/codingame.git
synced 2026-01-14 05:39:51 +01:00
30 lines
573 B
PHP
30 lines
573 B
PHP
<?php
|
|
// https://www.codingame.com/ide/puzzle/telephone-numbers
|
|
// Xavier Morel - 2016-03-17
|
|
|
|
$maintab = array();
|
|
$lines = (int) fgets(STDIN);
|
|
$result = 0;
|
|
|
|
$i = 0;
|
|
while ($i < $lines) {
|
|
$nbr = fgets(STDIN);
|
|
$nbr = trim($nbr);
|
|
|
|
$c = strlen($nbr);
|
|
$tab = &$maintab;
|
|
for ($j = 0; $j < $c; $j++) {
|
|
$number = $nbr[$j];
|
|
if (!isset($tab[$number])) {
|
|
$tab[$number] = array();
|
|
$result++;
|
|
$tab =& $tab[$number];
|
|
} else {
|
|
$tab =& $tab[$number];
|
|
}
|
|
}
|
|
$i++;
|
|
}
|
|
|
|
echo $result;
|