First algoritm complete for submission - prog4