RegexWars

Codewars, but the only language is regex.

next daily in --:--:--

Tier 3 · WarlockcaptureDaily #55

Name The Pair

A hand is five cards as "AS 7H 7D 9C KS" — rank then suit, space separated, and always sorted by rank, ascending. Capture the rank that appears more than once, or match nothing if every rank is different.

Sorted means duplicate ranks are neighbours, so you are comparing one rank with the rank exactly three characters later. The trap is that suits are neighbours too — a lazy pattern will happily report a shared suit as a pair, so make sure your group can only start where a card starts.

Your pattern0 chars · par 14
//
Flags
Start typing — tests run as you go.0 of 5 visible tests passing
Test cases
  • AS 7H 7D 9C KS→ ["7"]
  • AS AH 5D 9C KS→ ["A"]
  • 2S 2H 2D 9C KS→ ["2"]

    three of a kind counts

  • 2S 5H 9D TC KSmust not match
  • 2S 5S 9S TS KSmust not match

    five spades — a shared suit is not a pair

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

Solve it, then shrink it

Passing is the easy half. Your score is the length of your pattern, so the real competition starts once it turns green.

No accounts, no setup

Everything runs in your browser. Nothing to install, nothing to sign up for, and every challenge is free — permanently.

68 challenges, eight tiers

From matching a literal word to writing the regex that detects prime numbers. Browse them all.

RegexWars — Codewars, but the only language is regex