Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
IP network: route summarization solution in Uncategorized category for IP Network: Route Summarization by capback250
def checkio(nodes):
common, network = 0, []
for numOctet in range(4):
currentOctet = ''
for i in range(8):
charAtPos = ['{:08b}'.format(int(ip.split('.')[numOctet]))[i] for ip in nodes]
if len(set(charAtPos)) == 1:
currentOctet += charAtPos[0]
common += 1
else: break
if len(currentOctet) == 8:
network.append(str(int(currentOctet, 2)))
else:
currentOctet += '0' * (8 - len(currentOctet))
network.append(str(int(currentOctet, 2)))
break
return '{}/{}'.format('.'.join(network + ['0'] * (4 - len(network))), common)
March 16, 2016