Medium data structure and algorithm practice puzzle.
Given two IPv4 addresses as four octets each and a prefix length, return whether they share that prefix. A router asks this about every packet it forwards: same subnet means deliver it directly, different subnet means send it to the gateway. Compare octet by octet under a mask, and stop as soon as the prefix runs out rather than comparing the host part nobody asked about.
Solve it three ways: snap the jigsaw pieces together, fill in the blanks, or type it from scratch against the tests. This one is free.
Browse all 536 puzzles