added solution to q1-flattten