Porter Interview Question

Mostly sql queries and python code to print triangle