RegexWars
Tier 2 · Archmageextract

Clashes In The Box

A Sudoku box, flattened. Extract every digit that appears again later in the box.

Boards flatten row-major, top-left first, with (width − 1) hashes between rows — so a 3×3 box is three cells, ##, three cells, ##, three cells. An empty cell is a full stop. You want each occurrence that has a copy after it, which is why a digit appearing three times comes out twice. Finding the clash is easy; not consuming the rest of the box while you look is the challenge.

Your pattern1 chars · par 13
//g
Flags
Start typing — tests run as you go.0 of 5 visible tests passing
Test cases

Wrapped into rows of 3 so you can see the board. The string itself is one line with no line breaks in it — the 2 # between rows are ordinary characters, and a dot will happily match straight past them.

  • 123##
    456##
    789
    → []

    a legal box

  • 123##
    451##
    789
    → ["1"]
  • 123##
    423##
    789
    → ["2", "3"]
  • 111##
    ...##
    ...
    → ["1", "1"]

    three of a kind, two of them repeat

  • 1.3##
    .5.##
    7.9
    → []

+ 8 hidden tests, checked when you submit. They are what stops a pattern that only fits the examples above.