Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

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 EnderMartin Ender for a byte and to VenteroVentero for two bytes!

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!

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!

added 174 characters in body
Source Link
Doorknob
  • 71.7k
  • 20
  • 143
  • 385

Ruby, 25 24 23 1818 16 bytes

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

Try it online! 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.

  $_            gets  # read line of input
  / that was read automatically (-n)
   /!~/        /  # does not match the regex...
   \D0      \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!

Ruby, 25 24 23 18 bytes

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

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.

              gets  # read line of input
  /        /!~      # 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!

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!

added 92 characters in body
Source Link
Doorknob
  • 71.7k
  • 20
  • 143
  • 385

Ruby, 25 24 2323 18 bytes

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

Try it online!Try it online!

This is a procfull program that takes one argument, theinput in Ruby's canonical array to be testedformat on STDIN and outputs true or false on STDOUT.

->a{
"#{a}"              gets  # convertread argumentline toof stringinput
!~  /        /!~      # does not match the regex...
/   \D0              #   a non-digit (don't match "10"!) followed by a 0
      |             #   or...
       ^..$/         #   a 2-length string (signifyingwhich 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!

Ruby, 25 24 23 bytes

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

Try it online!

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

->a{
"#{a}"    # convert argument to string
!~        # does not match the regex...
/\D0      # a non-digit (don't match "10"!) followed by a 0
|         # or...
^..$/     # 2-length string (signifying the empty array)
}

Thanks to Martin Ender for a byte!

Ruby, 25 24 23 18 bytes

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

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.

              gets  # read line of input
  /        /!~      # 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!

added 92 characters in body
Source Link
Doorknob
  • 71.7k
  • 20
  • 143
  • 385
Loading
added 276 characters in body
Source Link
Doorknob
  • 71.7k
  • 20
  • 143
  • 385
Loading
added 46 characters in body
Source Link
Doorknob
  • 71.7k
  • 20
  • 143
  • 385
Loading
Post Undeleted by Doorknob
Post Deleted by Doorknob
Source Link
Doorknob
  • 71.7k
  • 20
  • 143
  • 385
Loading