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

Ruby, 21 + 1 = 22 19 + 1 = 20 bytes

Also throwing my hat into the Ruby battle using the regex approach (and improved using histocrat's suggestionhistocrat's suggestion):

p !/^(11+)\1+$|^1$/ 

Takes input as a unary string and invoked using the n flag:

$ ruby -ne 'p !/^(11+)\1+$|^1$/' <<< 11111 true 

Ruby, 21 + 1 = 22 19 + 1 = 20 bytes

Also throwing my hat into the Ruby battle using the regex approach (and improved using histocrat's suggestion):

p !/^(11+)\1+$|^1$/ 

Takes input as a unary string and invoked using the n flag:

$ ruby -ne 'p !/^(11+)\1+$|^1$/' <<< 11111 true 

Ruby, 21 + 1 = 22 19 + 1 = 20 bytes

Also throwing my hat into the Ruby battle using the regex approach (and improved using histocrat's suggestion):

p !/^(11+)\1+$|^1$/ 

Takes input as a unary string and invoked using the n flag:

$ ruby -ne 'p !/^(11+)\1+$|^1$/' <<< 11111 true 
deleted 53 characters in body
Source Link

Ruby, 2121 + 1 = 22 19 + 1 = 2220 bytes

Also throwing my hat into the Ruby battle using the regex approach (and improved using histocrat's suggestion):

p$_p !~/^(11+)\1+$|^1$/ 

Takes input as a unary string and invoked using the n flag:

$ ruby -ne 'p$_'p !~/^(11+)\1+$|^1$/' <<<11111<<< 11111 true 

Not better than the others, but also not worse, and I'm hoping I can find a way to squeeze one more byte out.

Ruby, 21 + 1 = 22 bytes

Also throwing my hat into the Ruby battle using the regex approach:

p$_!~/^(11+)\1+$|^1$/ 

Takes input as a unary string and invoked using the n flag:

$ ruby -ne 'p$_!~/^(11+)\1+$|^1$/' <<<11111 true 

Not better than the others, but also not worse, and I'm hoping I can find a way to squeeze one more byte out.

Ruby, 21 + 1 = 22 19 + 1 = 20 bytes

Also throwing my hat into the Ruby battle using the regex approach (and improved using histocrat's suggestion):

p !/^(11+)\1+$|^1$/ 

Takes input as a unary string and invoked using the n flag:

$ ruby -ne 'p !/^(11+)\1+$|^1$/' <<< 11111 true 
edited body
Source Link

Ruby, 21 + 1 = 22 bytes

Also throwing my hat into the Ruby battle using the regex approach:

p$_!~/^(..+11+)\1+$|^.$\1+$|^1$/ 

Takes input as a unary string and invoked using the n flag:

$ ruby -ne 'p$_!~/^(11+)\1+$|^1$/' <<<11111 true 

Not better than the others, but also not worse, and I'm hoping I can find a way to squeeze one more byte out.

Ruby, 21 + 1 = 22 bytes

Also throwing my hat into the Ruby battle using the regex approach:

p$_!~/^(..+)\1+$|^.$/ 

Takes input as a unary string and invoked using the n flag:

$ ruby -ne 'p$_!~/^(11+)\1+$|^1$/' <<<11111 true 

Not better than the others, but also not worse, and I'm hoping I can find a way to squeeze one more byte out.

Ruby, 21 + 1 = 22 bytes

Also throwing my hat into the Ruby battle using the regex approach:

p$_!~/^(11+)\1+$|^1$/ 

Takes input as a unary string and invoked using the n flag:

$ ruby -ne 'p$_!~/^(11+)\1+$|^1$/' <<<11111 true 

Not better than the others, but also not worse, and I'm hoping I can find a way to squeeze one more byte out.

Source Link
Loading