Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
18
Task/Abbreviations-automatic/PHP/abbreviations-automatic.php
Normal file
18
Task/Abbreviations-automatic/PHP/abbreviations-automatic.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
function genMinAbbr(array $days): array {
|
||||
$len = 0;
|
||||
while(true) {
|
||||
$dict = [];
|
||||
$len++;
|
||||
foreach($days as $day) {
|
||||
$abbr = substr($day, 0, $len);
|
||||
if (isset($dict[$abbr])) continue 2;
|
||||
$dict[$abbr] = true;
|
||||
}
|
||||
return array_keys($dict);
|
||||
}
|
||||
}
|
||||
|
||||
foreach(explode("\n", file_get_contents("days-of-the-week.txt")) as $line) {
|
||||
if (!$line) { echo "\n"; continue; }
|
||||
echo implode(" ", genMinAbbr(explode(" ", $line))) . "\n";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue