Let's define a generalized Cantor set by iteratively deleting some rational length segments from the middle of all intervals that haven't yet been deleted, starting from a single continuous interval.
Given the relative lengths of segments to delete or not, and the number of iterations to do, the problem is to write a program or function that outputs the relative lengths of the segments that have or have not been deleted after
Example: Iteratively delete the 4th and 6th eighth
n – number of iterations, indexed starting from 0 or 1
l – list of segment lengths as positive integers with
gcd(l)=1 and odd length, representing the relative lengths of the parts that either stay as they are or get deleted, starting from a segment that doesn't get deleted. Since the list length is odd, the first and last segments never get deleted.
For example for the regular Cantor set this would be [1,1,1] for one third that stays, one third that gets deleted and again one third that doesn't.
gcd(o)=1, of relative segment lengths in the
nth iteration when the segments that weren't deleted in the previous iteration are replaced by a scaled down copy of the list
l. The first iteration is just
. You can use any unambiguous output method, even unary.
n=0, l=[3,1,1,1,2] →  n=1, l=[3,1,1,1,2] → [3, 1, 1, 1, 2] n=2, l=[3,1,1,1,2] → [9,3,3,3,6,8,3,1,1,1,2,8,6,2,2,2,4] n=3, l=[5,2,3] → [125,50,75,100,75,30,45,200,75,30,45,60,45,18,27] n=3, l=[1,1,1] → [1,1,1,3,1,1,1,9,1,1,1,3,1,1,1]
You can assume the input is valid. This is code-golf, so the shortest program measured in bytes wins.