Advertisement
fbinnzhivko

Untitled

Sep 29th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function radio(input) {
  2.     let desireThickness = Number(input[0]);
  3.  
  4.     for (let i = 1; i < input.length; i++) {
  5.         let startingThikness = Number(input[i]);
  6.         let counter = 0;
  7.  
  8.         console.log('Processing chunk ' + startingThikness + ' microns');
  9.         while (startingThikness / 4 >= desireThickness) {
  10.             startingThikness /= 4;
  11.             counter++;
  12.         }
  13.         if (counter != 0) {
  14.             console.log('Cut x' + counter);
  15.             console.log('Transporting and washing');
  16.             if (startingThikness == desireThickness) {
  17.                 console.log('Finished crystal ' + startingThikness + ' microns');
  18.             }
  19.         }
  20.         startingThikness = Math.floor(startingThikness);
  21.         counter = 0;
  22.         while (startingThikness * 0.8 >= desireThickness) {
  23.             startingThikness *= 0.8;
  24.             counter++;
  25.         }
  26.         if (counter != 0) {
  27.             console.log('Lap x' + counter);
  28.             console.log('Transporting and washing');
  29.             if (startingThikness == desireThickness) {
  30.                 console.log('Finished crystal ' + startingThikness + ' microns');
  31.             }
  32.         }
  33.         startingThikness = Math.floor(startingThikness);
  34.         counter = 0;
  35.         while (startingThikness - 20 >= desireThickness) {
  36.             startingThikness -= 20;
  37.             counter++;
  38.         }
  39.         if (counter != 0) {
  40.             console.log('Grind x' + counter);
  41.             console.log('Transporting and washing');
  42.  
  43.             if (startingThikness == desireThickness) {
  44.                 console.log('Finished crystal ' + startingThikness + ' microns');
  45.                 break
  46.             }
  47.         }
  48.         counter = 0;
  49.         startingThikness = Math.floor(startingThikness);
  50.        
  51.         while (startingThikness -1 >= desireThickness) {
  52.             startingThikness -= 2;
  53.             counter++;
  54.         }
  55.         if (counter != 0) {
  56.             console.log('Etch x' + counter);
  57.             console.log('Transporting and washing');
  58.             if (startingThikness == desireThickness) {
  59.                 console.log('Finished crystal ' + startingThikness + ' microns');
  60.                 break
  61.             }
  62.         }        
  63.         startingThikness = Math.floor(startingThikness);
  64.         counter = 0;      
  65.  
  66.          if (startingThikness + 1 == desireThickness) {
  67.             console.log('X-ray x1');
  68.             console.log('Finished crystal ' + Number(startingThikness + 1) + ' microns');
  69.  
  70.         }
  71.     }
  72. }
  73. // radio([1375, 50000]);
  74. radio([1000, 4022]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement