Skip to content

Instantly share code, notes, and snippets.

@ovolve
ovolve / sumperms1234.ipynb
Last active May 17, 2016 22:30
Brute forcing a menacing maths problem
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ovolve
ovolve / sumregex.py
Last active September 6, 2018 03:23
import re
from random import randint
dfa = re.compile('((000|011|101)*(110(010|100|111)*001)*)*$')
def issum(A, B, C):
"""Return True iff non-negative integers A+B == C"""
strings = [bin(n)[:1:-1] for n in [A,B,C]]
maxlen = max(len(s) for s in strings)
padded = (s+'0'*(maxlen-len(s)) for s in strings)