Update 1079.py

added memorize function