Adding medium/hard puzzles & challenges...

This commit is contained in:
Xavier Morel
2017-04-06 16:49:53 +02:00
parent 50a3316969
commit 929c5f1912
24 changed files with 2930 additions and 1 deletions

View File

@@ -0,0 +1,29 @@
<?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;