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

  1. Draw the Netmask (Easy): Given a CIDR prefix length from 0 to 32, return the subnet mask as four numbers.
  2. 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.
  3. A Checksum That Notices Order (Medium, free): A plain sum cannot tell when two bytes have swapped places.
  4. A Length Hidden in Two Bits (Medium, free): QUIC, the protocol under HTTP/3, stores numbers in as few bytes as they need.
  5. Double, Then Creep (Medium, free): TCP does not know how fast the network is, so it probes.
  6. Highest Score Keeps the Key (Medium, free): To decide which server holds a key, score every server against that key and pick the highest.
  7. Save Up for a Burst (Medium, free): A token bucket allows short bursts while holding the long-run rate steady.
  8. 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.
  9. 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.
  10. Fold the Carry Back (Medium): Given a list of 16-bit numbers from a packet header, return its Internet checksum.
  11. 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.
  12. How Far Before It Dies (Medium): Given a distribution tree and a starting TTL, return how many nodes get the packet.
  13. How Many Got Through (Medium): Given sorted request times, a window length, and a limit, return how many requests are allowed.
  14. 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.
  15. How Many Islands of Routers (Medium): Given a network as an adjacency list, return how many separate pieces it's split into.
  16. 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.
  17. 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.
  18. Which Came Later (Medium): Given two 32-bit sequence numbers a and b, return true if a is newer than b.
  19. 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.
  20. 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.
  21. 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.
  22. 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