51 lines
1 KiB
PHP
51 lines
1 KiB
PHP
<?php
|
|
/**
|
|
* Auto-generated code below aims at helping you parse
|
|
* the standard input according to the problem statement.
|
|
**/
|
|
|
|
$letters = trim(stream_get_line(STDIN, 100, "\n"));
|
|
|
|
// Write an action using echo(). DON'T FORGET THE TRAILING \n
|
|
// To debug (equivalent to var_dump): error_log(var_export($var, true));
|
|
|
|
$resultat = [];
|
|
$bstring = '';
|
|
|
|
for ($u = 0; $u < strlen($letters); $u++) {
|
|
$binary = decbin(ord((string) $letters[$u]));
|
|
$_bstring = (string) $binary;
|
|
$_bstring = str_pad($_bstring, 7, '0', STR_PAD_LEFT);
|
|
|
|
$bstring.= $_bstring;
|
|
}
|
|
|
|
|
|
$p = 1;
|
|
$c = $bstring[0];
|
|
|
|
$value = $c == 1 ? '0' : '00';
|
|
$counter = 1;
|
|
|
|
while ($p < strlen($bstring) + 1) {
|
|
$nw = $bstring[$p];
|
|
|
|
if ($nw == $c) {
|
|
$counter++;
|
|
} else {
|
|
$resultat[] = $value.' '.str_repeat('0', $counter);
|
|
|
|
$c = $nw;
|
|
$counter = 1;
|
|
|
|
if ($value === '00') {
|
|
$value = '0';
|
|
} else {
|
|
$value = '00';
|
|
}
|
|
}
|
|
|
|
$p++;
|
|
}
|
|
|
|
echo implode(' ', $resultat), "\n"; |