@@ -0,0 +1,1256 @@
+#!/usr/bin/env python%0A%0A%0Aclass StarTree:%0A%0A    def __init__(self, levels):%0A%0A        # This algorithm doesn't actually%0A        # need any state here -- in Python,%0A        # it doesn't even need to be in a class.%0A%0A        # I'm making the first pass at all%0A        # the StarTrees feature some OOP%0A        # infrastructure to serve as an%0A        # accessible example and enable%0A        # some testing modularity in case%0A        # anyone wants to try timing the%0A        # different implementations and%0A        # languages against each other.%0A%0A        self.levels = levels%0A%0A    def print_tree(self):%0A%0A        # I spread this one out to make it more readable.%0A%0A        for each_level in range(1, (self.levels + 1)):%0A%0A            for each_row_index in range(0, (each_level + 1)):%0A%0A                spaces = %22 %22 * (self.levels - each_row_index)%0A                stars = %22*%22 * ((each_row_index * 2) + 1)%0A%0A                print(%22%7B%7D%7B%7D%22.format(spaces, stars))%0A%0A%0Aif __name__ == '__main__':%0A%0A    # For ease of testing, sys.argv%0A    # lets the user supply a number%0A    # to the program at execution.%0A    import sys%0A%0A    if len(sys.argv) == 2:%0A        tree_size = int(sys.argv%5B1%5D)%0A    else:%0A        tree_size = 3%0A%0A    new_tree = StarTree(tree_size)%0A    new_tree.print_tree()%0A

Add star_trees.py