Created
June 8, 2026 11:47
-
-
Save trikitrok/c4d8baed7d6b0f8c72c52105f118df01 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Behaviour: | |
| update the inventory of my store | |
| Input: inventory = [products] = [{sellin: x, Q: y, desc: "Theatre Passes"}, ...] | |
| Output: inventory' = [{sellin: x', Q: y', desc: "Theatre Passes"}, ...] | |
| Smaller behaviours: | |
| 1. Update sellin: | |
| - sellIn decreases by one for all products | |
| 2. Update Q: | |
| a. Regular product & sellIn > 0 => Q' = Q-2 | |
| *aI. examples de límite inferior Q | |
| b. Regular product & sellIn <= 0 => Q' = Q-4 | |
| *bI. examples de límite inferior Q | |
| c. Theatre Passes | |
| c1. Q' = Q + 1 when sellIn > 6 | |
| *c1I. examples de límite superior Q | |
| c2. Q' = Q + 3 when sellIn <= 6 & sellIn > 0 | |
| *c2I. examples de límite superior Q | |
| c3. Q' = 0 when sellIn <= 0 | |
| Invariants: | |
| 1. desc no cambia | |
| 2. Q € [0, 50] | |
| Ejemplos: | |
| [] => [] | |
| [{sellin: 30, Q: 5, desc: "Theatre Passes"}] => [{sellin: 29, Q: 6, desc: "Theatre Passes"}] | |
| *[{sellin: 30, Q: 50, desc: "Theatre Passes"}] => [{sellin: 29, Q: 50, desc: "Theatre Passes"}] | |
| [{sellin: 4, Q: 7, desc: "Theatre Passes"}] => [{sellin: 3, Q: 10, desc: "Theatre Passes"}] | |
| *[{sellin: 4, Q: 48, desc: "Theatre Passes"}] => [{sellin: 3, Q: 50, desc: "Theatre Passes"}] | |
| [{sellin: -5, Q: 48, desc: "Theatre Passes"}] => [{sellin: -6, Q: 0, desc: "Theatre Passes"}] | |
| [{sellin: 30, Q: 5, desc: "Bread"}] => [{sellin: 29, Q: 3, desc: "Bread"}] | |
| *[{sellin: 30, Q: 1, desc: "Bread"}] => [{sellin: 29, Q: 0, desc: "Bread"}] | |
| [{sellin: 0, Q: 15, desc: "coco"}] => [{sellin: -1, Q: 11, desc: "coco"}] | |
| *[{sellin: 0, Q: 2, desc: "coco"}] => [{sellin: -1, Q: 0, desc: "coco"}] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment