Skip to main content
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
  • 22.8k
  • 1
  • 20
  • 53

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
  • 22.8k
  • 1
  • 20
  • 53

Ruby, 21 bytes

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

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

Try it online!