Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
set solution in Clear category for IP Network: Route Summarization by gyahun_dash
from itertools import takewhile, chain
def checkio(adds):
binint = lambda strn: '{:0=8b}'.format(int(strn))
binseqs = (''.join(map(binint, a.split('.'))) for a in adds)
iscommon = lambda binset: len(binset) == 1
prefix = ''.join(chain(*takewhile(iscommon, map(set, zip(*binseqs)))))
filled = '{:0<32}'.format(prefix)
summary = '.'.join(str(int(filled[i: i + 8], 2)) for i in range(0, 32, 8))
return '{}/{}'.format(summary, len(prefix))
March 9, 2016