Skip to main content
deleted 1 character in body
Source Link
primo
  • 33.5k
  • 5
  • 61
  • 139

Perl - 4847 Bytes

#!perl -p054
{map$\+=($_%2x9^$'$_%2x9^lc$')!~/t/i~T,$&..$'*/\d+ ?-/}}{

Amended to pass the new test case.


Original

Perl - 36 Bytes

#!perl -p054
$\+=/\d+ ?-/*($'-$&>>/o|e/i)+1}{

Counting the shebang as 4, input is taken from stdin.


Sample Usage

$ echo pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even | perl math-problems.pl
27

$ echo pg. 34: 1 | perl math-problems.pl
1

$ echo PG. 565: 2-5,PG.345:7 | perl math-problems.pl
5

$ echo pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80 | perl math-problems.pl
70

Caveats

For even/odd ranges, it is expected that at least one of the endpoints matches the parity of the range. For example, 11-19 odd, 11-20 odd, and 10-19 odd will all be correctly counted as 5, but 10-20 odd will be over-counted as 6.

Perl - 48 Bytes

#!perl -p054
{map$\+=($_%2x9^$')!~/t/i,$&..$'*/\d+ ?-/}}{

Amended to pass the new test case.


Original

Perl - 36 Bytes

#!perl -p054
$\+=/\d+ ?-/*($'-$&>>/o|e/i)+1}{

Counting the shebang as 4, input is taken from stdin.


Sample Usage

$ echo pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even | perl math-problems.pl
27

$ echo pg. 34: 1 | perl math-problems.pl
1

$ echo PG. 565: 2-5,PG.345:7 | perl math-problems.pl
5

$ echo pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80 | perl math-problems.pl
70

Caveats

For even/odd ranges, it is expected that at least one of the endpoints matches the parity of the range. For example, 11-19 odd, 11-20 odd, and 10-19 odd will all be correctly counted as 5, but 10-20 odd will be over-counted as 6.

Perl - 47 Bytes

#!perl -p054
{map$\+=($_%2x9^lc$')!~T,$&..$'*/\d+ ?-/}}{

Amended to pass the new test case.


Original

Perl - 36 Bytes

#!perl -p054
$\+=/\d+ ?-/*($'-$&>>/o|e/i)+1}{

Counting the shebang as 4, input is taken from stdin.


Sample Usage

$ echo pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even | perl math-problems.pl
27

$ echo pg. 34: 1 | perl math-problems.pl
1

$ echo PG. 565: 2-5,PG.345:7 | perl math-problems.pl
5

$ echo pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80 | perl math-problems.pl
70

Caveats

For even/odd ranges, it is expected that at least one of the endpoints matches the parity of the range. For example, 11-19 odd, 11-20 odd, and 10-19 odd will all be correctly counted as 5, but 10-20 odd will be over-counted as 6.

deleted 1 character in body
Source Link
primo
  • 33.5k
  • 5
  • 61
  • 139

Perl - 4948 Bytes

#!perl -p054
{map$\+=$'!~map$\+=(T^lc$_%2$_%2x9^$')!~/t/i,$&..$'*lc=~$'*/\d+ ?-/}}{

Amended to pass the new test case.


Original

Perl - 36 Bytes

#!perl -p054
$\+=/\d+ ?-/*($'-$&>>/o|e/i)+1}{

Counting the shebang as 4, input is taken from stdin.


Sample Usage

$ echo pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even | perl math-problems.pl
27

$ echo pg. 34: 1 | perl math-problems.pl
1

$ echo PG. 565: 2-5,PG.345:7 | perl math-problems.pl
5

$ echo pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80 | perl math-problems.pl
70

Caveats

For even/odd ranges, it is expected that at least one of the endpoints matches the parity of the range. For example, 11-19 odd, 11-20 odd, and 10-19 odd will all be correctly counted as 5, but 10-20 odd will be over-counted as 6.

Perl - 49 Bytes

#!perl -p054
{map$\+=$'!~(T^lc$_%2),$&..$'*lc=~/\d+ ?-/}}{

Amended to pass the new test case.


Original

Perl - 36 Bytes

#!perl -p054
$\+=/\d+ ?-/*($'-$&>>/o|e/i)+1}{

Counting the shebang as 4, input is taken from stdin.


Sample Usage

$ echo pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even | perl math-problems.pl
27

$ echo pg. 34: 1 | perl math-problems.pl
1

$ echo PG. 565: 2-5,PG.345:7 | perl math-problems.pl
5

$ echo pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80 | perl math-problems.pl
70

Caveats

For even/odd ranges, it is expected that at least one of the endpoints matches the parity of the range. For example, 11-19 odd, 11-20 odd, and 10-19 odd will all be correctly counted as 5, but 10-20 odd will be over-counted as 6.

Perl - 48 Bytes

#!perl -p054
{map$\+=($_%2x9^$')!~/t/i,$&..$'*/\d+ ?-/}}{

Amended to pass the new test case.


Original

Perl - 36 Bytes

#!perl -p054
$\+=/\d+ ?-/*($'-$&>>/o|e/i)+1}{

Counting the shebang as 4, input is taken from stdin.


Sample Usage

$ echo pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even | perl math-problems.pl
27

$ echo pg. 34: 1 | perl math-problems.pl
1

$ echo PG. 565: 2-5,PG.345:7 | perl math-problems.pl
5

$ echo pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80 | perl math-problems.pl
70

Caveats

For even/odd ranges, it is expected that at least one of the endpoints matches the parity of the range. For example, 11-19 odd, 11-20 odd, and 10-19 odd will all be correctly counted as 5, but 10-20 odd will be over-counted as 6.

deleted 1 character in body
Source Link
primo
  • 33.5k
  • 5
  • 61
  • 139

Perl - 5049 Bytes

#!perl -p054
{$\+=grep$'map$\+=$'!~(T^lc$_%2),$&..$'*lc=~/\d+ ?-/}}{

Amended to pass the new test case.


Original

Perl - 36 Bytes

#!perl -p054
$\+=/\d+ ?-/*($'-$&>>/o|e/i)+1}{

Counting the shebang as 4, input is taken from stdin.


Sample Usage

$ echo pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even | perl math-problems.pl
27

$ echo pg. 34: 1 | perl math-problems.pl
1

$ echo PG. 565: 2-5,PG.345:7 | perl math-problems.pl
5

$ echo pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80 | perl math-problems.pl
70

Caveats

For even/odd ranges, it is expected that at least one of the endpoints matches the parity of the range. For example, 11-19 odd, 11-20 odd, and 10-19 odd will all be correctly counted as 5, but 10-20 odd will be over-counted as 6.

Perl - 50 Bytes

#!perl -p054
{$\+=grep$'!~(T^lc$_%2),$&..$'*lc=~/\d+ ?-/}}{

Amended to pass the new test case.


Original

Perl - 36 Bytes

#!perl -p054
$\+=/\d+ ?-/*($'-$&>>/o|e/i)+1}{

Counting the shebang as 4, input is taken from stdin.


Sample Usage

$ echo pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even | perl math-problems.pl
27

$ echo pg. 34: 1 | perl math-problems.pl
1

$ echo PG. 565: 2-5,PG.345:7 | perl math-problems.pl
5

$ echo pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80 | perl math-problems.pl
70

Caveats

For even/odd ranges, it is expected that at least one of the endpoints matches the parity of the range. For example, 11-19 odd, 11-20 odd, and 10-19 odd will all be correctly counted as 5, but 10-20 odd will be over-counted as 6.

Perl - 49 Bytes

#!perl -p054
{map$\+=$'!~(T^lc$_%2),$&..$'*lc=~/\d+ ?-/}}{

Amended to pass the new test case.


Original

Perl - 36 Bytes

#!perl -p054
$\+=/\d+ ?-/*($'-$&>>/o|e/i)+1}{

Counting the shebang as 4, input is taken from stdin.


Sample Usage

$ echo pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even | perl math-problems.pl
27

$ echo pg. 34: 1 | perl math-problems.pl
1

$ echo PG. 565: 2-5,PG.345:7 | perl math-problems.pl
5

$ echo pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80 | perl math-problems.pl
70

Caveats

For even/odd ranges, it is expected that at least one of the endpoints matches the parity of the range. For example, 11-19 odd, 11-20 odd, and 10-19 odd will all be correctly counted as 5, but 10-20 odd will be over-counted as 6.

deleted 3 characters in body
Source Link
primo
  • 33.5k
  • 5
  • 61
  • 139
Loading
added 2 characters in body
Source Link
primo
  • 33.5k
  • 5
  • 61
  • 139
Loading
added 3 characters in body
Source Link
primo
  • 33.5k
  • 5
  • 61
  • 139
Loading
deleted 10 characters in body
Source Link
primo
  • 33.5k
  • 5
  • 61
  • 139
Loading
added 166 characters in body
Source Link
primo
  • 33.5k
  • 5
  • 61
  • 139
Loading
deleted 5 characters in body
Source Link
primo
  • 33.5k
  • 5
  • 61
  • 139
Loading
Rollback to Revision 4
Source Link
primo
  • 33.5k
  • 5
  • 61
  • 139
Loading
edited body
Source Link
primo
  • 33.5k
  • 5
  • 61
  • 139
Loading
added 148 characters in body
Source Link
primo
  • 33.5k
  • 5
  • 61
  • 139
Loading
added 1 character in body
Source Link
primo
  • 33.5k
  • 5
  • 61
  • 139
Loading
deleted 1 character in body
Source Link
primo
  • 33.5k
  • 5
  • 61
  • 139
Loading
added 263 characters in body
Source Link
primo
  • 33.5k
  • 5
  • 61
  • 139
Loading
Source Link
primo
  • 33.5k
  • 5
  • 61
  • 139
Loading