Skip to main content
7 of 7
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/

Ruby, 25 24 23 18 16 bytes

p$_!~/\D0|^..$/

Requires the -n flag on the command line (+1 byte, -e -> -ne).

Try it online!

This is a full program that takes input in Ruby's canonical array format on STDIN and outputs true or false on STDOUT.

 $_              # line of input that was read automatically (-n)
   !~/        /  # does not match the regex...
      \D0        #   a non-digit followed by a 0
         |       #   or...
          ^..$   #   a 2-length string (which must be [], the empty array)
p                # output the result

23 byte function version:

->a{"#{a}"!~/\D0|^..$/}

This is a proc that takes one argument, the array to be tested.

Thanks to Martin Ender for a byte and to Ventero for two bytes!

Doorknob
  • 71.7k
  • 20
  • 143
  • 385