Now, almost in two weeks, I in another way would formulate the compression concept (hypothetical, of course, as its practicability is not proved). Namely, I would replace "flag" (which is not clear-what-length) with "chain addressing":
There is data - a bit line of length N, - which is required to be compressed, and standard .
1. In a cycle we sort out values seed (s), used for initialization : (s).
2. We write down s in the output file beginning.
3. By means of (s) it is generated casual sequence (joint venture) of the same length N.
4. We install "the counter of chain addressing" in a zero: =0.
5. Comparing and the joint venture, we move along both of them until it is found in them (to "the chain address") identical substring () by length of M.
6. If the notation of record of integer numbers used by us allow to write down these two numbers (And and) is shorter, than M of bits it is writeable them in the output file beginning. Also we write down in its end the next portion of not oblate bits - that went to (that is substring "is thrown out", we do not write to the output file).
(6.1. By the way, we can decide that with substrings is shorter 0 to communicate in essence does not follow; it is necessary then to write down not M, and difference -0 that is a little more favourable.)
7. If the condition described in item 6, is fulfilled, we pass to item 4; if it is not fulfilled - we pass to item 5. The further scanning of lines - anyway - proceeds from the first bit after Item substring
8. Reaching line end , we estimate the received variant of compression: if it is the best previous, we save it if is not present - is forgotten. Also we pass to item 1.