RegexWars
Tier 4 · Enchantermatch

Has X Won?

A noughts and crosses board arrives as one flat string. Match it only when X has three in a row — across, down, or diagonally.

The board is flattened row by row, top-left first, with . for an empty square. Between one row and the next sit 2 hash characters — one fewer than the width. That padding is the whole trick: it makes every direction a fixed stride. Left to right is 1 apart, straight down is 5, the down-right diagonal is 6, the down-left diagonal is 4 — and a diagonal that would fall off the edge lands on a hash instead of wrapping onto the next row. Eight lines, four strides.

Your pattern0 chars · par 40
//
Flags
Start typing — tests run as you go.0 of 6 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.

  • XXX##
    .O.##
    O..
    must match

    top row

  • X.O##
    X.O##
    X..
    must match

    left column

  • XO.##
    OX.##
    ..X
    must match

    diagonal

  • XOX##
    XOO##
    OXX
    must not match

    a full board nobody won

  • .X.##
    X..##
    .X.
    must not match

    three X, but not in a line

  • OOO##
    X.X##
    .X.
    must not match

    O won, not X

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