Inserting points in elements of a list
I would like to transform a list, for example:
A = [((1, 1), (1, 1, 1, 1)),
((1, 1), (1, 1, 1, 1)),
((1, 1), (1, 1, 1, 2)),
((1, 1), (1, 1, 1, 3)),
((1, 1), (1, 1, 2, 1)),
((1, 1), (1, 1, 3, 1)),
((1, 1), (1, 2, 1, 1)),
((1, 1), (1, 2, 1, 2)),
((1, 1), (1, 2, 1, 3)),
((1, 1), (1, 3, 1, 1)),
((1, 1), (1, 3, 1, 2))]
into
A = [((1, 1, 0), (1, 1, 1, 1)),
((1, 1, 0), (1, 1, 1, 1)),
((1, 1, 0), (1, 1, 1, 2)),
((1, 1, 1), (1, 1, 1, 3)),
((1, 1, 1), (1, 1, 2, 1)),
((1, 1, 1), (1, 1, 3, 1)),
((1, 1, 2), (1, 2, 1, 1)),
((1, 1, 2), (1, 2, 1, 2)),
((1, 1, 2), (1, 2, 1, 3)),
((1, 1, 3), (1, 3, 1, 1)),
((1, 1, 3), (1, 3, 1, 2))]
Any suggestions?
Can you describe the algorithm used to convert from the old list to the new one? Is it just inserting zero at the end of the 0th tuple in your pair, and then increasing the inserted integer by 1 every three times?
Yes, it is exactly that. I would like to do that in a list that has
len(A) = 108
.