Given a set of values that are suppose to be presented in a pattern, create a pattern that reflects the percentages. Ultimately these values are going to be images that have to be displayed a certain percentage of the time, but need to be in a pattern that attempts to show a different image each time.
Example:
Given: A @ 40%, B @ 20%, C @ 10%, D @ 10%, E @ 10%
Conditions: Prefer to not have a repeat, but ultimately is still allowed Percentage increments will only be by 1. (IE: never will have 12.5%) Number of different of values may increase or decrease.
Pattern: BACADAEAB
Currently I'm doing this by hand and hard coding it whenever the values change. I know there's a formula to find the Least Common Multiple (LCM), but it relies on a Greatest Common Divisor (GCD) which seems to be trickier to code.
I don't have any code just yet, the formula I'm trying to replicate is:
lcm(v1, v2, ...) = (|v1 x v2 x ...|)/(gcd(v1, v2, ...))
Aucun commentaire:
Enregistrer un commentaire