Working Solution

Algorithm works on provided inputs from prof