Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Logic behind stock generator:
- command = 1 1 2 2 3 6 6 6 6 6 6 7 8
- db = 2 6 6 6 9
- default_stock = 12
- command_sum = 60
- Reverse loop the command
- each element is checked vs last db element
- if command element is > db element, we will add default stock
- if command element is <= db element, we will add db element
- if command element is default_stock/2, we will check if we can use db element
- if we can use db element, we will.
- if we can't use db element, we will count how many of default_stock/2 elements we have.
- 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.
- when we get divided number, that will be amount of default stocks that need to be added to matrix.
- Example:
- ROW 1:
- 9 is because 8 < 9
- 12 is because 8 > 6
- 6 is because 6=6
- 6 is because 6=6
- 6 is because 6=6
- 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)
- sum is now 63 and we stop
- ROW 2:
- 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 }
- 12 is because 3 > 2
- sum is now 63 and we stop
- ROW 3:
- 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 }
- 2 is because 2=2
- 12 is because we don't have db stock to compare 2
- sum is now 65 and we stop
- ROW 4 and 5:
- 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
- Matrix results for default stock 12 should look like this:
- ROW 1 = 9 12 6 6 6 12 12 = 63
- ROW 2 = 9 12 6 6 6 12 12 = 63
- ROW 3 = 9 12 6 6 6 12 2 12 = 65
- ROW 4 = 9 12 6 6 6 12 2 12 = 65
- ROW 5 = 9 12 6 6 6 12 2 12 = 65
- Software output:
- 9000 12000 6000 6000 6000 12000 12000
- 9000 6000 6000 6000 12000 12000 12000
- 9000 6000 6000 6000 12000 12000 2000 12000
- 9000 6000 6000 6000 12000 2000 12000 12000
- 9000 6000 6000 6000 2000 12000 12000 12000
- ------------------------------------------------------------------------------------
- other output for other default stock:
- default stock = 14
- 9000 14000 6000 6000 6000 14000 14000
- 9000 6000 6000 6000 14000 14000 14000
- 9000 6000 6000 6000 14000 14000 14000
- 9000 6000 6000 6000 14000 14000 2000 14000
- 9000 6000 6000 6000 14000 2000 14000 14000
- 9000 6000 6000 6000 2000 14000 14000 14000
- default stock = 16
- 9000 16000 6000 6000 6000 16000 16000
- 9000 6000 6000 6000 16000 16000 16000
- 9000 6000 6000 6000 16000 16000 16000
- 9000 6000 6000 6000 16000 16000 2000
- 9000 6000 6000 6000 16000 2000 16000
- 9000 6000 6000 6000 2000 16000 16000
- 9000 6000 6000 6000 2000 16000 16000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement