Advertisement
MartinGeorgiev

Rage Quit

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