Easy data structure and algorithm practice puzzle.
Given a CIDR prefix length from 0 to 32, return the subnet mask as four numbers. So /24 is [255, 255, 255, 0]. The mask is that many 1 bits followed by 0s, split into four bytes of 8 bits. Each byte takes up to 8 of the 1 bits. The tricky one is a length that stops mid-byte: /12 gives [255, 240, 0, 0].
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.
Every line of the solution comes with a note explaining why it is there, and a step by step replay shows the code running. At level 3, where you type it yourself, you can ask for an AI mock interview on this problem that ends with a hiring manager's scorecard.
Browse all 546 puzzles