Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
7-liner without modules solution in Clear category for IP Network: Route Summarization by Phil15
def checkio(ips):
bin_ips = [''.join(f'{int(n):08b}' for n in ip.split('.')) for ip in ips]
first_bin_ip = bin_ips[0]
subnet = min(k for k, bits in enumerate(zip(*bin_ips)) if len(set(bits))!=1)
route = first_bin_ip[:subnet] + first_bin_ip[subnet:].replace('1','0')
route = '.'.join(str(int(route[8*k:8*k+8], 2)) for k in range(4))
return f'{route}/{subnet}'
Oct. 11, 2018