Background: We have software that displays different products to the user
Problem: With a given set of rules, determine which is the primary product we should show the user. These are images. We are writing this in Python, but I don't think that matters.
Rules:
These don't really matter so I'm just going to abbreviate them. I can calculate a boolean return value for each of these. What matters is that some must match completely, some must match in an order of precedence.
Rule Notes
Rule_1 The image HAS to have this.
Rule_2 The image HAS to have this.
Rule_3 The image HAS to have this.
Rule_4 (see the next two for actual rule) The image must match one of the following:
Rule_4a If image is this, use it
Rule_4b Otherwise, use this
Rule_5 The image must match one of the following in order (descending preference)
Rule_5a If this passes, then this image could be used
Rule_5b If this is a different type, lets say a "front" image, use this
Rule_5c If this is another type, "back" of the product image.
Rule_6 This image must be at least this size
What I'm thinking:
I'm thinking of iterating through the list of images, and attaching a score to each one and then returning the highest score.
Problem with that:
I'm not sure how to handle the priority order (let me know if that is making sense). Best way I can state it is that some of these are &&
and some of these are ||
, but I don't know how to do ||
in precedence like this.