Slightly cleaned up version of 03_triangle

Break out some things into functions to make more readable