Langford Sequence Visualizer

A Langford sequence arranges the numbers 1, 1, 2, 2, ..., n, n so that the two copies of any number k are separated by exactly k other spaces. In this visualization, each generated row represents a unique valid sequence, with each number mapped to a distinct color.


Current choice for n: 4

  • Press Up / Down Arrows to change n (Input Mode only).
  • Press 's' to start sequence generation.
  • Press 'i' to iterate further once imaged.
  • Press 'r' to reset the program.