Skip to content

Instantly share code, notes, and snippets.

@evjeny
Created October 9, 2017 15:53
Show Gist options
  • Save evjeny/c6112dbb17b2991b5d03dbce9a42c583 to your computer and use it in GitHub Desktop.
Save evjeny/c6112dbb17b2991b5d03dbce9a42c583 to your computer and use it in GitHub Desktop.
def gip(msk,adrs):
ma = [int(i) for i in msk.split(".")]
da = [int(i) for i in adrs.split(".")]
res = ""
for j in range(4):
c = ma[j]&da[j]
if j!=3:
res += str(c) + "."
else:
res += str(c)
return res
a = input()
n = int(input())
k = []
for i in range(n):
c = input()
k.append(gip(a,c))
d = set(k)
print(len(d))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment