Objects/Documentation
periodes28.py
Counting format changes by period · periodes28.py
Download ↓"""Count sign runs by concatenating periodic blocks rather than scanning every word count."""
from poids27 import sizes
import json
def sign(n):
bits=n.bit_length();pad=(-1-13*((n+63)//64)-18*n)%8
delta=(2*bits-1-pad+7)//8-(bits+6)//7
return (delta>0)-(delta<0)
def summary(seq):
return (seq[0],seq[-1],1+sum(a!=b for a,b in zip(seq,seq[1:])))
def join(a,b):
if not a:return b
if not b:return a
return a[0],b[1],a[2]+b[2]-(a[1]==b[0])
def repeat(block,count):
if not count:return None