So I have x number of items, each one has its own appearance ratio for making a pattern, of which I'm trying to determine the smallest possible pattern. The appearance ratios for all items total up to 1.
This is a bit of a complicated question to get my head around so I'll try and explain with examples…
For example there may be four letters (a, b, c, d) with respective ratios of 0.4, 0.3, 0.2, 0.1, which would require a minimum pattern size of 10 (as 0.1 is the smallest ratio, and 0.1 / 1 = 10). Resulting pattern would be aaaabbbccd.
In another example, of 0.4, 0.4, 0.2 we would get a minimum pattern size of 5 (aabbc).
However an example of 0.3, 0.3, 0.4 would require a pattern size of 10 (aaabbbcccc) because the 0.4 cannot be divided by the 0.3 without resulting in a decimal.
What algorithm could calculate the pattern size based on the input ratios?