even(x) = x / 2
odd(x) = (3 * x) + 1
L_1 = Sequence(30)
L_2 = Sequence((L_1(k), 1), k, 1, 30)
spacing: 1
L_3 = Sequence(Segment[L_2((2 * k)), (even(x(L_2((2 * k)))), 1 + spacing)], k, 1, 15)
L_4 = Sequence(Segment[L_2((2 * k) - 1), (odd(x(L_2((2 * k) - 1))), 1 + spacing)], k, 1, 15)
L_5 = Sequence(If[IsInteger[L_1(k) / 2], even(L_1(k)), odd(L_1(k))], k, 1, 30)
L_6 = Sequence((L_5(k), 1 + spacing), k, 1, 30)
L_7 = Sequence(If[IsInteger[L_5(k) / 2], even(L_5(k)), odd(L_5(k))], k, 1, 30)
L_8 = Sequence((L_7(k), 1 + (2 * spacing)), k, 1, 30)
L_9 = Sequence(If[IsInteger[L_7(k) / 2], even(L_7(k)), odd(L_7(k))], k, 1, 30)
L_{10} = Sequence((L_9(k), 1 + (3 * spacing)), k, 1, 30)
L_{11} = Sequence(If[IsInteger[L_9(k) / 2], even(L_9(k)), odd(L_9(k))], k, 1, 30)
L_{12} = Sequence((L_{11}(k), 1 + (4 * spacing)), k, 1, 30)
L_{13} = Sequence(If[IsInteger[L_{11}(k) / 2], even(L_{11}(k)), odd(L_{11}(k))], k, 1, 30)
L_{14} = Sequence((L_{13}(k), 1 + (5 * spacing)), k, 1, 30)
L_{15} = Sequence(If[IsInteger[L_{13}(k) / 2], even(L_{13}(k)), odd(L_{13}(k))], k, 1, 30)
L_{16} = Sequence((L_{15}(k), 1 + (6 * spacing)), k, 1, 30)
L_{17} = Sequence(Segment[L_6(k), L_8(k)], k, 1, 30)
L_{18} = Sequence(Segment[L_8(k), L_{10}(k)], k, 1, 30)
L_{19} = Sequence(Segment[L_{10}(k), L_{12}(k)], k, 1, 30)
L_{20} = Sequence(Segment[L_{12}(k), L_{14}(k)], k, 1, 30)
L_{21} = Sequence(Segment[L_{14}(k), L_{16}(k)], k, 1, 30)