[ prog / sol / mona ]

prog


LISP Puzzles

82 2020-05-08 10:36

It occured to me that it makes more sense to make seqN_covered output a vector instead of a scalar, in the way that seqN_inc already returns a vector. The purpose of the separation between seqN_covered and seqN_inc is to perform the minimal amount of upfront work that determines whether a group fits, then if it does perform the more expensive work of summing it. The determination computes how many S entries are needed and whether this count fits into 'n', the targeted R index. But seqN_covered currently only returns the final S count, even though it might need to compute additional information on the way to obtaining it. This additional information is thrown away in seq4_covered >>67 as the incS value, only to be recomputed in seq4_inc as incS1. In seq3_inc >>36 the countS computation duplicates the work of seq3_covered. It is better to pass all the additional information along from seqN_covered to seqN_inc and avoid recomputation, because it appears that this pattern of reuse will hold for all higher S-groups. The reused information comes from the layers >>81.

157


VIP:

do not edit these