Advertisement
Guest User

RadioCrystals

a guest
Aug 27th, 2019
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.82 KB | None | 0 0
  1. <?php
  2. $input = explode(", ", readline());
  3. $finalResult = array_shift($input);
  4.  
  5. foreach ($input as $startWeigth) {
  6.     echo "Processing chunk $startWeigth microns" . PHP_EOL;
  7.     $count = 0;
  8.     while (Cut($startWeigth) >= $finalResult) {
  9.         $count++;
  10.         $startWeigth = Cut($startWeigth);
  11.     }
  12.     if ($count > 0) {
  13.         echo "Cut x$count" . PHP_EOL;
  14.         $startWeigth = TransportingAndWashing($startWeigth);
  15.     }
  16.     $count = 0;
  17.     while (Lap($startWeigth) >= $finalResult) {
  18.         $count++;
  19.         $startWeigth = Lap($startWeigth);
  20.     }
  21.     if ($count != 0) {
  22.         echo "Lap x$count" . PHP_EOL;
  23.         $startWeigth = TransportingAndWashing($startWeigth);
  24.     }
  25.     $count = 0;
  26.     while (Grind($startWeigth) >= $finalResult) {
  27.         $count++;
  28.         $startWeigth = Grind($startWeigth);
  29.     }
  30.     if ($count > 0) {
  31.         echo "Grind x$count" . PHP_EOL;
  32.         $startWeigth = TransportingAndWashing($startWeigth);
  33.     }
  34.     $count = 0;
  35.     while (Etch($startWeigth) >= $finalResult - 1) {
  36.         $count++;
  37.         $startWeigth = Etch($startWeigth);
  38.     }
  39.     if ($count > 0) {
  40.         echo "Etch x$count" . PHP_EOL;
  41.         $startWeigth = TransportingAndWashing($startWeigth);
  42.     }
  43.  
  44.     if ($startWeigth == $finalResult - 1) {
  45.         $startWeigth = Xray($startWeigth);
  46.         echo "X-ray x1" . PHP_EOL;
  47.     }
  48.  
  49.     echo "Finished crystal $startWeigth microns" . PHP_EOL;;
  50. }
  51.  
  52. function TransportingAndWashing($a)
  53. {
  54.     echo "Transporting and washing" . PHP_EOL;
  55.     return floor($a);
  56. }
  57.  
  58. function Cut($a)
  59. {
  60.     $a /= 4;
  61.     return $a;
  62. }
  63.  
  64. function Lap($a)
  65. {
  66.     $a -= 0.2 * $a;
  67.     return $a;
  68. }
  69.  
  70. function Grind($a)
  71. {
  72.     $a -= 20;
  73.     return $a;
  74. }
  75.  
  76. function Etch($a)
  77. {
  78.     $a -= 2;
  79.     return $a;
  80. }
  81.  
  82. function Xray($a)
  83. {
  84.     $a += 1;
  85.     return $a;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement