← Questions

Fill a BIN range with card brand intervals

0
StripeCodingLast asked Nov 2024

A six-digit BIN covers every 16-digit card number that starts with it; the other ten digits run from 0000000000 to 9999999999. You get a list of inclusive suffix intervals, each labelled with a card brand. To hide exactly where each brand's range starts and ends, stretch the intervals until together they cover the whole BIN range, and return them as full 16-digit numbers sorted by start.

  1. The intervals are contiguous: extend the first down to the start of the range and the last up to its end.
  2. There may be gaps between intervals: give each gap to the interval below it.
  3. Some intervals sit inside others: leave the nested ones unchanged and stretch only the outer ones.
  4. Merge neighbouring intervals of the same brand into one.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding