Advertisement
thezxtreme

alg_out_19_01_16

Jan 19th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. Logic behind stock generator:
  2.  
  3. command = 1 1 2 2 3 6 6 6 6 6 6 7 8
  4. db = 2 6 6 6 9
  5. default_stock = 12
  6. command_sum = 60
  7.  
  8.  
  9. Reverse loop the command
  10. each element is checked vs last db element
  11. if command element is > db element, we will add default stock
  12. if command element is <= db element, we will add db element
  13. if command element is default_stock/2, we will check if we can use db element
  14. if we can use db element, we will.
  15. if we can't use db element, we will count how many of default_stock/2 elements we have.
  16. we will if number is odd, we will do that count/2 +1 or if count is not odd number, we will do count/2.
  17. when we get divided number, that will be amount of default stocks that need to be added to matrix.
  18.  
  19.  
  20. Example:
  21.  
  22. ROW 1:
  23. 9 is because 8 < 9
  24. 12 is because 8 > 6
  25. 6 is because 6=6
  26. 6 is because 6=6
  27. 6 is because 6=6
  28. 12 12 is because we have 3x 12/2 in our command left, with will be odd number, so we use formula (3 div 2)+1 = 1 + 1 = 2; (means we added 2x 12 to matrix)
  29. sum is now 63 and we stop
  30.  
  31. ROW 2:
  32. we copy our current row to next row and we remove one default stock, on our case is 12, so row number 2 looks like { 9 12 6 6 6 12 }
  33. 12 is because 3 > 2
  34. sum is now 63 and we stop
  35.  
  36. ROW 3:
  37. we copy our current row to next row and we remove one default stock, on our case is 12, so row number 3 looks like { 9 12 6 6 6 12 }
  38. 2 is because 2=2
  39. 12 is because we don't have db stock to compare 2
  40. sum is now 65 and we stop
  41.  
  42. ROW 4 and 5:
  43. and row 4 and 5 should look the same like row 3, because we remove one default stock and replace it with the same value because we don't have db stock
  44.  
  45.  
  46. Matrix results for default stock 12 should look like this:
  47. ROW 1 = 9 12 6 6 6 12 12 = 63
  48. ROW 2 = 9 12 6 6 6 12 12 = 63
  49. ROW 3 = 9 12 6 6 6 12 2 12 = 65
  50. ROW 4 = 9 12 6 6 6 12 2 12 = 65
  51. ROW 5 = 9 12 6 6 6 12 2 12 = 65
  52.  
  53. Software output:
  54. 9000 12000 6000 6000 6000 12000 12000
  55. 9000 6000 6000 6000 12000 12000 12000
  56. 9000 6000 6000 6000 12000 12000 2000 12000
  57. 9000 6000 6000 6000 12000 2000 12000 12000
  58. 9000 6000 6000 6000 2000 12000 12000 12000
  59.  
  60.  
  61.  
  62. ------------------------------------------------------------------------------------
  63. other output for other default stock:
  64.  
  65.  
  66.  
  67. default stock = 14
  68. 9000 14000 6000 6000 6000 14000 14000
  69. 9000 6000 6000 6000 14000 14000 14000
  70. 9000 6000 6000 6000 14000 14000 14000
  71. 9000 6000 6000 6000 14000 14000 2000 14000
  72. 9000 6000 6000 6000 14000 2000 14000 14000
  73. 9000 6000 6000 6000 2000 14000 14000 14000
  74.  
  75.  
  76. default stock = 16
  77. 9000 16000 6000 6000 6000 16000 16000
  78. 9000 6000 6000 6000 16000 16000 16000
  79. 9000 6000 6000 6000 16000 16000 16000
  80. 9000 6000 6000 6000 16000 16000 2000
  81. 9000 6000 6000 6000 16000 2000 16000
  82. 9000 6000 6000 6000 2000 16000 16000
  83. 9000 6000 6000 6000 2000 16000 16000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement