All puzzles › Networking
Networking Practice Problems
22 puzzles (2 easy, 16 medium, 4 hard), 7 free, in Python, JavaScript and C++.
The algorithms that move a packet. Longest prefix match down a routing trie, OSPF as Dijkstra, multicast pruning, the Internet checksum, and why TCP can wrap past four billion and cope.
The puzzles, easiest first
- Draw the Netmask (Easy): Given a CIDR prefix length from 0 to 32, return the subnet mask as four numbers.
- Wait Longer Each Time (Easy): Given an attempt number (starting at 0), a base delay, and a cap, return how long to wait before retrying.
- A Checksum That Notices Order (Medium, free): A plain sum cannot tell when two bytes have swapped places.
- A Length Hidden in Two Bits (Medium, free): QUIC, the protocol under HTTP/3, stores numbers in as few bytes as they need.
- Double, Then Creep (Medium, free): TCP does not know how fast the network is, so it probes.
- Highest Score Keeps the Key (Medium, free): To decide which server holds a key, score every server against that key and pick the highest.
- Save Up for a Burst (Medium, free): A token bucket allows short bursts while holding the long-run rate steady.
- What Is Still Missing (Medium, free): With selective acknowledgment, a receiver reports exactly which blocks of data arrived, so the sender resends only the holes.
- Which Route Wins (Medium, free): The internet's routers often learn several routes to the same place, and BGP breaks the tie with a fixed list of rules.
- Fold the Carry Back (Medium): Given a list of 16-bit numbers from a packet header, return its Internet checksum.
- Hold It Until It Fits (Medium): Given packet numbers in the order they arrive, and the number you expect first, return how many packets you can deliver in order by the end.
- How Far Before It Dies (Medium): Given a distribution tree and a starting TTL, return how many nodes get the packet.
- How Many Got Through (Medium): Given sorted request times, a window length, and a limit, return how many requests are allowed.
- How Many Hops (Medium): Given a network as an adjacency list and two routers, return the fewest hops between them, or -1 if there's no path.
- How Many Islands of Routers (Medium): Given a network as an adjacency list, return how many separate pieces it's split into.
- Prune the Branches Nobody Watches (Medium): Given a tree where a node holds 1 if it has a subscriber and 0 if it doesn't, return how many nodes are left after pruning.
- Same Side of the Wall (Medium): Given two IPv4 addresses as four numbers each and a prefix length, return true if they're on the same subnet, meaning their first prefix-length bits match.
- Which Came Later (Medium): Given two 32-bit sequence numbers a and b, return true if a is newer than b.
- Round and Round (Hard): Given a forwarding table where next[i] is the router that i sends packets to, or -1 if i delivers them itself, return true if any packet could go around in circles forever.
- The Cheapest Route (Hard): Given the number of routers, a list of two-way links as [a, b, cost], and two routers, return the cheapest total cost between them, or -1 if you can't get there.
- The Deepest Match Wins (Hard): Given a routing tree and an address as a list of bits, return the next hop of the most specific route that matches, or 0 if none does.
- Two Routes That Could Be One (Hard): Given a routing tree where each node holds a next-hop ID, or 0 for no route, return how many nodes have two children that could be merged into it.
Practice another pattern
Or browse by subject
Browse all 676 puzzles