##Perl (no +/-, no tie-breakers, 29 chars)##
s!!xx!;s!x!$"x<>!eg;say y!!!c
As a bonus, you can make the code sum more than two numbers by adding more xs to the s!!xx!.
Alternatively, here are two 21-char solutions with 1 and 3 tie-breakers respectively
say length$"x<>.$"x<>
say log exp(<>)*exp<>
Note: These solutions use the say function, available since Perl 5.10.0 with the -E command line switch or with use 5.010. See the edit history of this answer edit history of this answer for versions that work on older perls.
How does the solution with no tie-breakers work?
s!!xx!is a regexp replacement operator, operating by default on the$_variable, which replaces the empty string with the stringxx. (Usually/is used as the regexp delimiter in Perl, but really almost any character can be used. I chose!since it's not a tie-breaker.) This is just a fancy way of prepending"xx"to$_— or, since$_starts out empty (undefined, actually), it's really a way to write$_ = "xx"without using the equals sign (and with one character less, too).`s!x!$"x!eg` is another regexp replacement, this time replacing each `x` in `$_` with the value of the expression `$" x `. (The `g` switch specifies global replacement, `e` specifies that the replacement is to be evaluated as Perl code instead of being used as a literal string.) `$"` is a [special variable](http://perldoc.perl.org/perlvar.html#$LIST_SEPARATOR) whose default value happens to be a single space; using it instead of `" "` saves one char. (Any other variable known to have a one-character value, such as `$&` or `$/`, would work equally well here, except that using `$/` would cost me a tie-breaker.)
The `` [line input operator](http://perldoc.perl.org/perlop.html#I%2fO-Operators), in scalar context, reads one line from standard input and returns it. The `x` before it is the Perl [string repetition operator](http://perldoc.perl.org/perlop.html#Multiplicative-Operators), and is really the core of this solution: it returns its left operand (a single space character) repeated the number of times given by its right operand (the line we just read as input).
y!!!cis just an obscure way to (ab)use the transliteration operator to count the characters in a string ($_by default, again). I could've just writtensay length, but the obfuscated version is one character shorter. :)
##Perl (no +/-, no tie-breakers, 29 chars)##
s!!xx!;s!x!$"x<>!eg;say y!!!c
As a bonus, you can make the code sum more than two numbers by adding more xs to the s!!xx!.
Alternatively, here are two 21-char solutions with 1 and 3 tie-breakers respectively
say length$"x<>.$"x<>
say log exp(<>)*exp<>
Note: These solutions use the say function, available since Perl 5.10.0 with the -E command line switch or with use 5.010. See the edit history of this answer for versions that work on older perls.
How does the solution with no tie-breakers work?
s!!xx!is a regexp replacement operator, operating by default on the$_variable, which replaces the empty string with the stringxx. (Usually/is used as the regexp delimiter in Perl, but really almost any character can be used. I chose!since it's not a tie-breaker.) This is just a fancy way of prepending"xx"to$_— or, since$_starts out empty (undefined, actually), it's really a way to write$_ = "xx"without using the equals sign (and with one character less, too).`s!x!$"x!eg` is another regexp replacement, this time replacing each `x` in `$_` with the value of the expression `$" x `. (The `g` switch specifies global replacement, `e` specifies that the replacement is to be evaluated as Perl code instead of being used as a literal string.) `$"` is a [special variable](http://perldoc.perl.org/perlvar.html#$LIST_SEPARATOR) whose default value happens to be a single space; using it instead of `" "` saves one char. (Any other variable known to have a one-character value, such as `$&` or `$/`, would work equally well here, except that using `$/` would cost me a tie-breaker.)
The `` [line input operator](http://perldoc.perl.org/perlop.html#I%2fO-Operators), in scalar context, reads one line from standard input and returns it. The `x` before it is the Perl [string repetition operator](http://perldoc.perl.org/perlop.html#Multiplicative-Operators), and is really the core of this solution: it returns its left operand (a single space character) repeated the number of times given by its right operand (the line we just read as input).
y!!!cis just an obscure way to (ab)use the transliteration operator to count the characters in a string ($_by default, again). I could've just writtensay length, but the obfuscated version is one character shorter. :)
##Perl (no +/-, no tie-breakers, 29 chars)##
s!!xx!;s!x!$"x<>!eg;say y!!!c
As a bonus, you can make the code sum more than two numbers by adding more xs to the s!!xx!.
Alternatively, here are two 21-char solutions with 1 and 3 tie-breakers respectively
say length$"x<>.$"x<>
say log exp(<>)*exp<>
Note: These solutions use the say function, available since Perl 5.10.0 with the -E command line switch or with use 5.010. See the edit history of this answer for versions that work on older perls.
How does the solution with no tie-breakers work?
s!!xx!is a regexp replacement operator, operating by default on the$_variable, which replaces the empty string with the stringxx. (Usually/is used as the regexp delimiter in Perl, but really almost any character can be used. I chose!since it's not a tie-breaker.) This is just a fancy way of prepending"xx"to$_— or, since$_starts out empty (undefined, actually), it's really a way to write$_ = "xx"without using the equals sign (and with one character less, too).`s!x!$"x!eg` is another regexp replacement, this time replacing each `x` in `$_` with the value of the expression `$" x `. (The `g` switch specifies global replacement, `e` specifies that the replacement is to be evaluated as Perl code instead of being used as a literal string.) `$"` is a [special variable](http://perldoc.perl.org/perlvar.html#$LIST_SEPARATOR) whose default value happens to be a single space; using it instead of `" "` saves one char. (Any other variable known to have a one-character value, such as `$&` or `$/`, would work equally well here, except that using `$/` would cost me a tie-breaker.)
The `` [line input operator](http://perldoc.perl.org/perlop.html#I%2fO-Operators), in scalar context, reads one line from standard input and returns it. The `x` before it is the Perl [string repetition operator](http://perldoc.perl.org/perlop.html#Multiplicative-Operators), and is really the core of this solution: it returns its left operand (a single space character) repeated the number of times given by its right operand (the line we just read as input).
y!!!cis just an obscure way to (ab)use the transliteration operator to count the characters in a string ($_by default, again). I could've just writtensay length, but the obfuscated version is one character shorter. :)
##Perl (no +/-, no tie-breakers, 2829 chars)##
s!!xx!;s!x!1x<>$"x<>!eg;say y!!!c
As a bonus, you can make the code sum more than two numbers by adding more xs to the s!!xx!.
Alternatively, here are two 21-char solutions with 1 and 3 tie-breakers respectively
say length$"x<>.$"x<>
say log exp(<>)*exp<>
Note: These solutions use the say function, available since Perl 5.10.0 with the -E command line switch or with use 5.010. See the edit history of this answer for versions that work on older perls.
How does the solution with no tie-breakers work?
s!!xx!is a regexp replacement operator, operating by default on the$_variable, which replaces the empty string with the stringxx. (Usually/is used as the regexp delimiter in Perl, but really almost any character can be used. I chose!since it's not a tie-breaker.) This is just a fancy way of prepending"xx"to$_— or, since$_starts out empty (undefined, actually), it's really a way to write$_ = "xx"without using the equals sign (and with one character less, too).`s!x!1x$"x!eg` is another regexp replacement, this time replacing each `x` in `$_` with the value of the expression `1`$" x `. (The `g` switch specifies global replacement, `e` specifies that the replacement is to be evaluated as Perl code instead of being used as a literal string.) `$"` is a [special variable](http://perldoc.perl.org/perlvar.html#$LIST_SEPARATOR) whose default value happens to be a single space; using it instead of `" "` saves one char. (Any other variable known to have a one-character value, such as `$&` or `$/`, would work equally well here, except that using `$/` would cost me a tie-breaker.)
The `` [line input operator](http://perldoc.perl.org/perlop.html#I%2fO-Operators), in scalar context, reads one line from standard input and returns it. The `x` before it is the Perl [string repetition operator](http://perldoc.perl.org/perlop.html#Multiplicative-Operators), and is really the core of this solution: it returns its left operand (the number `1`a single space character) repeated the number of times given by its right operand (the line we just read as input).
y!!!cis just an obscure way to (ab)use the transliteration operator to count the characters in a string ($_by default, again). I could've just writtensay length, but the obfuscated version is one character shorter. :)
##Perl (no +/-, no tie-breakers, 28 chars)##
s!!xx!;s!x!1x<>!eg;say y!!!c
As a bonus, you can make the code sum more than two numbers by adding more xs to the s!!xx!.
Alternatively, here are two 21-char solutions with 1 and 3 tie-breakers respectively
say length$"x<>.$"x<>
say log exp(<>)*exp<>
Note: These solutions use the say function, available since Perl 5.10.0 with the -E command line switch or with use 5.010. See the edit history of this answer for versions that work on older perls.
How does the solution with no tie-breakers work?
s!!xx!is a regexp replacement operator, operating by default on the$_variable, which replaces the empty string with the stringxx. (Usually/is used as the regexp delimiter in Perl, but really almost any character can be used. I chose!since it's not a tie-breaker.) This is just a fancy way of prepending"xx"to$_— or, since$_starts out empty (undefined, actually), it's really a way to write$_ = "xx"without using the equals sign (and with one character less, too).`s!x!1x!eg` is another regexp replacement, this time replacing each `x` in `$_` with the value of the expression `1 x `. (The `g` switch specifies global replacement, `e` specifies that the replacement is to be evaluated as Perl code instead of being used as a literal string.)
The `` [line input operator](http://perldoc.perl.org/perlop.html#I%2fO-Operators), in scalar context, reads one line from standard input and returns it. The `x` before it is the Perl [string repetition operator](http://perldoc.perl.org/perlop.html#Multiplicative-Operators), and is really the core of this solution: it returns its left operand (the number `1`) repeated the number of times given by its right operand (the line we just read as input).
y!!!cis just an obscure way to (ab)use the transliteration operator to count the characters in a string ($_by default, again). I could've just writtensay length, but the obfuscated version is one character shorter. :)
##Perl (no +/-, no tie-breakers, 29 chars)##
s!!xx!;s!x!$"x<>!eg;say y!!!c
As a bonus, you can make the code sum more than two numbers by adding more xs to the s!!xx!.
Alternatively, here are two 21-char solutions with 1 and 3 tie-breakers respectively
say length$"x<>.$"x<>
say log exp(<>)*exp<>
Note: These solutions use the say function, available since Perl 5.10.0 with the -E command line switch or with use 5.010. See the edit history of this answer for versions that work on older perls.
How does the solution with no tie-breakers work?
s!!xx!is a regexp replacement operator, operating by default on the$_variable, which replaces the empty string with the stringxx. (Usually/is used as the regexp delimiter in Perl, but really almost any character can be used. I chose!since it's not a tie-breaker.) This is just a fancy way of prepending"xx"to$_— or, since$_starts out empty (undefined, actually), it's really a way to write$_ = "xx"without using the equals sign (and with one character less, too).`s!x!$"x!eg` is another regexp replacement, this time replacing each `x` in `$_` with the value of the expression `$" x `. (The `g` switch specifies global replacement, `e` specifies that the replacement is to be evaluated as Perl code instead of being used as a literal string.) `$"` is a [special variable](http://perldoc.perl.org/perlvar.html#$LIST_SEPARATOR) whose default value happens to be a single space; using it instead of `" "` saves one char. (Any other variable known to have a one-character value, such as `$&` or `$/`, would work equally well here, except that using `$/` would cost me a tie-breaker.)
The `` [line input operator](http://perldoc.perl.org/perlop.html#I%2fO-Operators), in scalar context, reads one line from standard input and returns it. The `x` before it is the Perl [string repetition operator](http://perldoc.perl.org/perlop.html#Multiplicative-Operators), and is really the core of this solution: it returns its left operand (a single space character) repeated the number of times given by its right operand (the line we just read as input).
y!!!cis just an obscure way to (ab)use the transliteration operator to count the characters in a string ($_by default, again). I could've just writtensay length, but the obfuscated version is one character shorter. :)
- 21k
- 5
- 55
- 101
##Perl (no +/-, no tie-breakers, 2928 chars)##
s!!xx!;s!x!$"x<>1x<>!eg;say y!!!c
As a bonus, you can make the code sum more than two numbers by adding more xs to the s!!xx!.
Alternatively, here are two 21-char solutions with 1 and 3 tie-breakers respectively
say length$"x<>.$"x<>
say log exp(<>)*exp<>
Note: These solutions use the say function, available since Perl 5.10.0 with the -E command line switch or with use 5.010. See the edit history of this answer for versions that work on older perls.
How does the solution with no tie-breakers work?
s!!xx!is a regexp replacement operator, operating by default on the$_variable, which replaces the empty string with the stringxx. (Usually/is used as the regexp delimiter in Perl, but really almost any character can be used. I chose!since it's not a tie-breaker.) This is just a fancy way of prepending"xx"to$_— or, since$_starts out empty (undefined, actually), it's really a way to write$_ = "xx"without using the equals sign (and with one character less, too).`s!x!$"x1x!eg` is another regexp replacement, this time replacing each `x` in `$_` with the value of the expression `$"`1 x `. (The `g` switch specifies global replacement, `e` specifies that the replacement is to be evaluated as Perl code instead of being used as a literal string.) `$"` is a [special variable](http://perldoc.perl.org/perlvar.html#$LIST_SEPARATOR) whose default value happens to be a single space; using it instead of `" "` saves one char. (Any other variable known to have a one-character value, such as `$&` or `$/`, would work equally well here, except that using `$/` would cost me a tie-breaker.)
The `` [line input operator](http://perldoc.perl.org/perlop.html#I%2fO-Operators), in scalar context, reads one line from standard input and returns it. The `x` before it is the Perl [string repetition operator](http://perldoc.perl.org/perlop.html#Multiplicative-Operators), and is really the core of this solution: it returns its left operand (a single space characterthe number `1`) repeated the number of times given by its right operand (the line we just read as input).
y!!!cis just an obscure way to (ab)use the transliteration operator to count the characters in a string ($_by default, again). I could've just writtensay length, but the obfuscated version is one character shorter. :)
##Perl (no +/-, no tie-breakers, 29 chars)##
s!!xx!;s!x!$"x<>!eg;say y!!!c
As a bonus, you can make the code sum more than two numbers by adding more xs to the s!!xx!.
Alternatively, here are two 21-char solutions with 1 and 3 tie-breakers respectively
say length$"x<>.$"x<>
say log exp(<>)*exp<>
Note: These solutions use the say function, available since Perl 5.10.0 with the -E command line switch or with use 5.010. See the edit history of this answer for versions that work on older perls.
How does the solution with no tie-breakers work?
s!!xx!is a regexp replacement operator, operating by default on the$_variable, which replaces the empty string with the stringxx. (Usually/is used as the regexp delimiter in Perl, but really almost any character can be used. I chose!since it's not a tie-breaker.) This is just a fancy way of prepending"xx"to$_— or, since$_starts out empty (undefined, actually), it's really a way to write$_ = "xx"without using the equals sign (and with one character less, too).`s!x!$"x!eg` is another regexp replacement, this time replacing each `x` in `$_` with the value of the expression `$" x `. (The `g` switch specifies global replacement, `e` specifies that the replacement is to be evaluated as Perl code instead of being used as a literal string.) `$"` is a [special variable](http://perldoc.perl.org/perlvar.html#$LIST_SEPARATOR) whose default value happens to be a single space; using it instead of `" "` saves one char. (Any other variable known to have a one-character value, such as `$&` or `$/`, would work equally well here, except that using `$/` would cost me a tie-breaker.)
The `` [line input operator](http://perldoc.perl.org/perlop.html#I%2fO-Operators), in scalar context, reads one line from standard input and returns it. The `x` before it is the Perl [string repetition operator](http://perldoc.perl.org/perlop.html#Multiplicative-Operators), and is really the core of this solution: it returns its left operand (a single space character) repeated the number of times given by its right operand (the line we just read as input).
y!!!cis just an obscure way to (ab)use the transliteration operator to count the characters in a string ($_by default, again). I could've just writtensay length, but the obfuscated version is one character shorter. :)
##Perl (no +/-, no tie-breakers, 28 chars)##
s!!xx!;s!x!1x<>!eg;say y!!!c
As a bonus, you can make the code sum more than two numbers by adding more xs to the s!!xx!.
Alternatively, here are two 21-char solutions with 1 and 3 tie-breakers respectively
say length$"x<>.$"x<>
say log exp(<>)*exp<>
Note: These solutions use the say function, available since Perl 5.10.0 with the -E command line switch or with use 5.010. See the edit history of this answer for versions that work on older perls.
How does the solution with no tie-breakers work?
s!!xx!is a regexp replacement operator, operating by default on the$_variable, which replaces the empty string with the stringxx. (Usually/is used as the regexp delimiter in Perl, but really almost any character can be used. I chose!since it's not a tie-breaker.) This is just a fancy way of prepending"xx"to$_— or, since$_starts out empty (undefined, actually), it's really a way to write$_ = "xx"without using the equals sign (and with one character less, too).`s!x!1x!eg` is another regexp replacement, this time replacing each `x` in `$_` with the value of the expression `1 x `. (The `g` switch specifies global replacement, `e` specifies that the replacement is to be evaluated as Perl code instead of being used as a literal string.)
The `` [line input operator](http://perldoc.perl.org/perlop.html#I%2fO-Operators), in scalar context, reads one line from standard input and returns it. The `x` before it is the Perl [string repetition operator](http://perldoc.perl.org/perlop.html#Multiplicative-Operators), and is really the core of this solution: it returns its left operand (the number `1`) repeated the number of times given by its right operand (the line we just read as input).
y!!!cis just an obscure way to (ab)use the transliteration operator to count the characters in a string ($_by default, again). I could've just writtensay length, but the obfuscated version is one character shorter. :)