Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

Ruby, 21 bytes

->x{x*?!!~/[^2!]|22/}

Using a regex is actually shorter, because joining an array also flattens it.

##How it works

How it works

->x{
 x*?! -> Join array using an exclamation mark
 !~ -> String does not contain
 /[^2!] -> characters different from '2' or '!'
 | -> or
 22/ -> '2' repeated at least twice
 }

Try it online!

Ruby, 21 bytes

->x{x*?!!~/[^2!]|22/}

Using a regex is actually shorter, because joining an array also flattens it.

##How it works

->x{
 x*?! -> Join array using an exclamation mark
 !~ -> String does not contain
 /[^2!] -> characters different from '2' or '!'
 | -> or
 22/ -> '2' repeated at least twice
 }

Try it online!

Ruby, 21 bytes

->x{x*?!!~/[^2!]|22/}

Using a regex is actually shorter, because joining an array also flattens it.

How it works

->x{
 x*?! -> Join array using an exclamation mark
 !~ -> String does not contain
 /[^2!] -> characters different from '2' or '!'
 | -> or
 22/ -> '2' repeated at least twice
 }

Try it online!

added 348 characters in body
Source Link
G B
  • 23.4k
  • 1
  • 24
  • 55

Ruby, 21 bytes

->x{x*?!!~/[^2!]|22/}

Using a regex is actually shorter, because joining an array also flattens it.

##How it works

->x{
 x*?! -> Join array using an exclamation mark
 !~ -> String does not contain
 /[^2!] -> characters different from '2' or '!'
 | -> or
 22/ -> '2' repeated at least twice
 }

Try it online!

Ruby, 21 bytes

->x{x*?!!~/[^2!]|22/}

Using a regex is actually shorter, because joining an array also flattens it.

Try it online!

Ruby, 21 bytes

->x{x*?!!~/[^2!]|22/}

Using a regex is actually shorter, because joining an array also flattens it.

##How it works

->x{
 x*?! -> Join array using an exclamation mark
 !~ -> String does not contain
 /[^2!] -> characters different from '2' or '!'
 | -> or
 22/ -> '2' repeated at least twice
 }

Try it online!

Source Link
G B
  • 23.4k
  • 1
  • 24
  • 55

Ruby, 21 bytes

->x{x*?!!~/[^2!]|22/}

Using a regex is actually shorter, because joining an array also flattens it.

Try it online!

AltStyle によって変換されたページ (->オリジナル) /