Advertisement
Guest User

Untitled

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