Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. function radioCrystals(input) {
  2. let desiredThickness = Number(input[0])
  3. let count = 0
  4. for (i=1; i < input.length; i++) {
  5. let thickness = Number(input[i])
  6. console.log("Processing chunk " + thickness + " microns")
  7. while (thickness > desiredThickness) {
  8. thickness = thickness / 4
  9. count++
  10. if (thickness < desiredThickness) {
  11. thickness = thickness * 4
  12. count--
  13. console.log("Cut x" + count)
  14. console.log("Transporting and washing")
  15. break;
  16. }
  17. else if (thickness == desiredThickness) {
  18. console.log("Cut x" + count)
  19. console.log("Transporting and washing")
  20. }
  21. }
  22. thickness = Math.floor(thickness)
  23. count = 0
  24. while (thickness > desiredThickness) {
  25. let lastValue = thickness * 20 / 100
  26. thickness = thickness - (thickness * 20 / 100)
  27. count++;
  28. if (thickness < desiredThickness) {
  29. thickness = thickness + lastValue
  30. count--
  31. console.log("Lap x" + count)
  32. console.log("Transporting and washing")
  33. break;
  34. }
  35. else if (thickness == desiredThickness) {
  36. console.log("Lap x" + count)
  37. console.log("Transporting and washing")
  38. }
  39. }
  40. thickness = Math.floor(thickness)
  41. count = 0
  42. while (thickness > desiredThickness) {
  43. thickness = thickness - 20
  44. count++
  45. if (thickness < desiredThickness) {
  46. thickness = thickness + 20
  47. count--
  48. console.log("Grind x" + count)
  49. console.log("Transporting and washing")
  50. break;
  51. }
  52. else if (thickness == desiredThickness) {
  53. console.log("Grind x" + count)
  54. console.log("Transporting and washing")
  55. }
  56. }
  57. thickness = Math.floor(thickness)
  58. count = 0
  59. while (thickness > desiredThickness) {
  60. thickness = thickness - 2
  61. count++
  62. // if (thickness < desiredThickness) {
  63. // thickness = thickness + 2
  64. // count--
  65. // console.log("Etch x" + count)
  66. // console.log("Transporting and washing")
  67. // break
  68.  
  69. // }
  70. if (thickness < desiredThickness) {
  71. console.log("Etch x" + count)
  72. console.log("Transporting and washing")
  73. break;
  74. }
  75. else if (thickness == desiredThickness) {
  76. console.log("Etch x" + count)
  77. console.log("Transporting and washing")
  78. }
  79. }
  80. thickness = Math.floor(thickness)
  81. count = 0
  82. while (thickness < desiredThickness) {
  83. thickness = thickness + 1
  84. count++
  85. console.log("X-ray x" + count)
  86. }
  87. count = 0
  88. if (thickness == desiredThickness) {
  89. console.log("Finished crystal " + desiredThickness + " microns")
  90. }
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement