RegexWars
Tier 3 · Warlockmatch

Legal Hand

Match a well-formed hand: exactly five cards, single space separated, each a rank from A23456789TJQK followed by a suit from SHDC — and no card appearing twice. Hands are always sorted by rank, ascending.

The shape is the easy half. The interesting half is that one deck holds one seven of hearts: no card may repeat. The trap is assuming sorted order puts a repeat next to its twin. It does not — the hand is sorted by RANK, and the suits inside a rank block are in no order at all, so the ten of spades can appear twice with another ten sitting between them. A repeat has to be forbidden anywhere later in the hand, not just in the next position, which means stepping over whole cards to look for it.

Your pattern0 chars · par 69
//
Flags
Start typing — tests run as you go.0 of 7 visible tests passing
Test cases
  • AS 2H 5D 9C KSmust match
  • 2S 2H 2D 2C 5Smust match

    four of a kind is four different cards

  • AS 2H 5D 9Cmust not match

    only four cards

  • AS 2H 5D 9C 1Smust not match

    1 is not a rank

  • AS 2H 5D 9C KXmust not match

    X is not a suit

  • 7H 7H 8D 9C KSmust not match

    the seven of hearts twice

  • AH TS TH TS TDmust not match

    the ten of spades twice, with another ten between them

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