Skip to main content
Commonmark migration
Source Link

##Ruby, 9 bytes (8 + -n flag)

Ruby, 9 bytes (8 + -n flag)

p~/1/||1 

Input 2 integers separated by comma or space or semicolon or just whatever.

###Explanation:

Explanation:

If the input string does not contain any '1', output '1' (since the sum can't be one).

If the input string is 3 characters long, the position of the first one can be 0 or 2, the sum can't be zero, and only '1 1' has sum two (but the first '1' is at position zero).

If the input string is longer, we don't care, the sum will be bigger than one and bigger than the position of the first '1'.

##Ruby, 9 bytes (8 + -n flag)

p~/1/||1 

Input 2 integers separated by comma or space or semicolon or just whatever.

###Explanation:

If the input string does not contain any '1', output '1' (since the sum can't be one).

If the input string is 3 characters long, the position of the first one can be 0 or 2, the sum can't be zero, and only '1 1' has sum two (but the first '1' is at position zero).

If the input string is longer, we don't care, the sum will be bigger than one and bigger than the position of the first '1'.

Ruby, 9 bytes (8 + -n flag)

p~/1/||1 

Input 2 integers separated by comma or space or semicolon or just whatever.

Explanation:

If the input string does not contain any '1', output '1' (since the sum can't be one).

If the input string is 3 characters long, the position of the first one can be 0 or 2, the sum can't be zero, and only '1 1' has sum two (but the first '1' is at position zero).

If the input string is longer, we don't care, the sum will be bigger than one and bigger than the position of the first '1'.

added 418 characters in body
Source Link
G B
  • 23.4k
  • 1
  • 24
  • 55

##Ruby, 9 bytes (8 + -n flag)

p~/1/||1 

Input 2 integers separated by comma or space or semicolon or just whatever.

###Explanation:

If the input string does not contain any '1', output '1' (since the sum can't be one).

If the input string is 3 characters long, the position of the first one can be 0 or 2, the sum can't be zero, and only '1 1' has sum two (but the first '1' is at position zero).

If the input string is longer, we don't care, the sum will be bigger than one and bigger than the position of the first '1'.

##Ruby, 9 bytes (8 + -n flag)

p~/1/||1 

Input 2 integers separated by comma or space or semicolon or just whatever.

##Ruby, 9 bytes (8 + -n flag)

p~/1/||1 

Input 2 integers separated by comma or space or semicolon or just whatever.

###Explanation:

If the input string does not contain any '1', output '1' (since the sum can't be one).

If the input string is 3 characters long, the position of the first one can be 0 or 2, the sum can't be zero, and only '1 1' has sum two (but the first '1' is at position zero).

If the input string is longer, we don't care, the sum will be bigger than one and bigger than the position of the first '1'.

Source Link
G B
  • 23.4k
  • 1
  • 24
  • 55

##Ruby, 9 bytes (8 + -n flag)

p~/1/||1 

Input 2 integers separated by comma or space or semicolon or just whatever.