An array of combinations is generated from two arrays,
indices: 0 1 2 3 4 5
array 1: [a, b]
array 2: [A, B, C]
repeating array 1: a, b, a, b, a, b
repeating array 2: A, B, C, A, B, C
combinations: [aA, bB, aC, bA, aB, bC] length = LCM(2, 3)
INPUT : a, C
OUTPUT: 2, which the index of aC in the generated combinations.
Say, when a
and C
are given whose indices are already known as 0
and 2
in the original arrays, how to find the index of aC
, which is 2
? Is there any algorithmic way to do this?
For detailed background information, please check version 1 of this question.