Q:

problem calculating subnet mask

Question in some competition exam:
The subnet mask for a particular network is 255.255.31.0. Which of the following pairs of IP addressed could belong to this network?

1: 172.57.88.62 & 172.56.87.23
2: 10.35.28.2 & 10.35.29.4
3: 191.203.31.87 & 192.234.31.88
4: 128.8.129.43 & 128.8.161.55

Now I am having a confusion in this question that i have read that a subnet mask is of pattern:
1111 1111. 1111 1111. 1111 1
I mean 1's start from left side but in this subnet mask:
1111 1111. 1111 1111. 0001 1111. 0000 0000

So what is the actual principle behind. please explain. i am totally confused.
Thanks in advance :)

A:

That's a discontiguous subnet mask, which is no longer supported on most routers. The principle is the same: convert the dotted-quad IP addresses and mask to 32-bit unsigned integers and AND each address with the mask. If the results are the same, they're in the same subnet.

