Python quiz (found here)
import re def blackbox(num): return not re.match(r"^1?$|^(11+?)\1+$", "1"*num)