Add solution 1 implementation in python