Combinatorial Geometry Algorithm (synthetic)
Here's my attempt at trimming it down. Note that there's no real reason to prefix variables with the_. Also list comprehensions can help with making code more concise, removing the need for total_triangles() entirely.
def make_triangles(lines: [(float, float)]) -&gt; [(float, float, float)]:
    &quot;&quot;&quot;
    :param lines: the lines to make triangles from
    :return: the triangles
    time: O(len(lines) * len(lines)
    space: O(len(lines) * len(lines))
    &quot;&quot;&quot;
    triangles: [(float, float, float)] = []
    for ax, ay in lines:
        for bx, by in lines:
            if ax == bx and ay != by:
                triangles.append((ax, ay, by))
            if ax == by and ax != bx:
                triangles.append((ax, ay, bx))
    return triangles


def print_sums(sums: [float]) -&gt; None:
    &quot;&quot;&quot;
    :param the_sums: the calculated sums
    :return: None
    Output: std output
    &quot;&quot;&quot;
    row = 0
    for number in sums:
        if row % 3 == 0:
            print('', end='\n')
        print(str(number), end=&quot; &quot;)
        row = row + 1
    print('\n', end='')


def main() -&gt; None:
    &quot;&quot;&quot;
    Entry point for script
    :return: None
    Input: None
    Output: std output
    &quot;&quot;&quot;
    lines = [(0.0, 1.0), (1.0, 2.0), (2.0, 3.0)]
    triangles = make_triangles(lines)
    sums = [ sum(triangle) for triangle in triangles ]
    print_sums(sums)


if __name__ == &quot;__main__&quot;:
    main()