A little context:Book has 411 PagesRead a random number of pages on the first day which is unknownNumber of pages to read next day is the square of the sum of the digits of the page currently onI.e. on Page 36: read 81 pages next dayOn day 6 The square answer directly adds to current page number to make 411Finish BookHow many pages did she read on the first day and how many pages did  she read on the 6 days?This is what I have so far:from itertools import accumulate, countdef read_book( start ):    for i in range( 6 ): yield start; start += sum( int( digit ) for digit in str( start ) ) ** 2def find_start( pages ):    for start in count( 1 ):        for read in read_book( start ): pass        if read == pages: return startprevious_answer, start = 0, find_start( 411 )for i, read in enumerate( read_book( start ), 1 ):    print( Pages read on day, i ,was, read-previous_answer ,\t(Now on page, str(read) + )\n)    previous_answer += read-previous_answerOutput:Pages read on day 1 was 61 (Now on page 61)Pages read on day 2 was 49 (Now on page 110)Pages read on day 3 was 4 (Now on page 114)Pages read on day 4 was 36 (Now on page 150)Pages read on day 5 was 36 (Now on page 186)Pages read on day 6 was 225 (Now on page 411)Is there a more efficient way of writing this using fewer lines of code?
Books Algorithm Dealing with Square Digit Sums
python;optimization;python 3.x