Add first attempt of solution 397 problem