Coin Flip

by Jakob Degen

Keith has been very bored with his job as an industrial couponer lately, and so he has decided to spend his time flipping coins. The results of his coin flips are in this file, with each bit representing the outcome of one bit. Keith now wants to know how many runs of flips he found. A run is any consecutive sequence of the same flip. For example, the flips 001111101011 have three runs of length one, two runs of length two, and one run of length five. Can you help Keith count runs? The flag is the number of runs or length one, the number of runs of length two, the number of runs of length three, etc. up to the longest run in the sequence, each separated by a comma and space.

results matching ""

    No results matching ""