Advertisement
MartinGeorgiev

Untitled

Nov 20th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: Marto
  5.  * Date: 21/11/18
  6.  * Time: 00:40
  7.  */
  8. $string = readline();
  9. $countUniqueSymbols = 0;
  10. $stringCountRepeat = 0;
  11. $tempString = '';
  12. $newString = '';
  13. for ($i = 0; $i < strlen($string); $i++) {
  14.     $currentChar = $string[$i];
  15.     if (is_numeric($currentChar) !== true) {
  16.         $tempString .= $currentChar;
  17.     } else {
  18.         if ($i + 1 < strlen($string)) {
  19.             $nextChar = $string[$i + 1];
  20.             if (is_numeric($nextChar)) {
  21.                 $currentChar .= $nextChar;
  22.             }
  23.         }
  24.         $stringCountRepeat = intval($currentChar);
  25.         $newString .= str_repeat(strtoupper($tempString), $stringCountRepeat);
  26.         $tempString = '';
  27.     }
  28. }
  29. $rageMessage = array_unique(str_split($newString));
  30. echo "Unique symbols used: " . count($rageMessage) . PHP_EOL;
  31. echo $newString;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement