added my code and pseudocode