[Tutor] Count for loops

Neil Cerutti neilc at norwich.edu
Wed Apr 5 10:43:00 EDT 2017


On 2017-04-03, Mats Wichmann <mats at wichmann.us> wrote:
> If you're talking about 4-digit year numbers using a Western
> calendar in digits of PI, the overlap effect seems unlikely to
> matter - let's say the year is 1919, do we think PI contains
> the sequence 191919? count would report back one instead of two
> in that case. In other cases it might matter; count is written
> specifically to not care about overlaps: "Return the number of
> (non-overlapping) occurrences"  So that's worth keeping in mind
> when you think about what you need from substrings-in-strings
> cases.

Composing a FSA (finite state automata) by hand would be an
excellent exercise in addition to covering the overlapping cases.

Another fun exercise might be to find the bithdays using
arithmetic operations instead of string operations.

-- 
Neil Cerutti



More information about the Tutor mailing list