Ruby, 25 24 23 18 16 bytes
p$_!~/\D0|^..$/
Requires the -n
flag on the command line (+1 byte, -e
-> -ne
).
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 EnderMartin Ender for a byte and to VenteroVentero for two bytes!