I'm trying to design this algorithm that creates arrays like:[1,1,0] which means "White Sedan car with no stickers" in randomized fashion.
But I got some constrains and explanations to do;
The dict. looks like this:
carParts =[
{name: "chasis", count: 2, attrNames: ["sedan", "suv"], attrLimit:[5, 3], attrType: ["a","a"], required: true},
{name: "paint", count: 3, attrNames: ["white", "blue", "red"], attrLimit:[6, 1, 1], attrType: ["a","l","s"], required: true},
{name: "sticker", count: 2, attrNames: ["s line", "pull flower"], attrLimit:[1, 1], attrType: ["u","s"], required: false}
]
"name:" is part name
"count:" is how many different attributes there are on belonging part "attrNames:" names of attributes
"attrLimit:" count of how many cars can get belonging attribute. e.g. There can be only 6 white cars.
"attType:" a: all, l:luxery, s:sport. These are flags that determines which car can get which attribute. e.g. if sedan has an "red" color, it can only get "pull flower" sticker or no stickers since stickers are not required.
"required:" states that if Part is required or not. If is not required, it can be empty(0).
Feel free to edit dict. if it looks wrong. This is my first time using dicts. and objects like these so I might have messed up.
My expected output is: 8 strings that looks like this: (8 that there will be no more chassis left)
cars{[1,3,2],[1,1,0],[2,1,1]....]
I need to understand logic behind more than plug and play code, since I will try to implement my own version after hopefully catching some tricks here, researching on them and understand well. So any explanations and notes like "search this concept to understand better" would be appriciated.
Aucun commentaire:
Enregistrer un commentaire