Skip to main content
Commonmark migration
Source Link

My teacher always gives me the most complicated set of math problems for homework. Like: pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even. And I want to know in advance how much time to set aside for my homework, but I don't want to have to figure all that out. That's why its your task to program it for me.

##Specifications

Specifications

  • You will get a string detailing the problems that I have to complete as args, stdio, etc.
  • They will be comma separated (possibly comma-space separated)
  • It will include single problems in the form of just a number (e.g. 79)
  • And ranges in the form 17-18 (again, you have to deal with optional spaces)
  • The ranges are inclusive of both ends
  • The ranges will optionally be suffixed by odd or even, which you have to take into account.
  • A set of ranges/pages will be prepended by a page number in the form pg. 545: , again having to deal with optional spaces. You can safely ignore these, as you need to get the problems over all the pages
  • The text may be in uppercase or lowercase, but will not be both.
  • Return, stdout, etc. the number of problems I have to do for homework.
  • Since this is , shortest code in bytes wins!

##Test Cases

Test Cases

pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even   ->    27
pg. 34: 1                                                    ->    1
PG. 565: 2-5,PG.345:7                                        ->    5
pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80                ->    70
pg.492: 2-4 odd,7-9 even                                     ->    2

My teacher always gives me the most complicated set of math problems for homework. Like: pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even. And I want to know in advance how much time to set aside for my homework, but I don't want to have to figure all that out. That's why its your task to program it for me.

##Specifications

  • You will get a string detailing the problems that I have to complete as args, stdio, etc.
  • They will be comma separated (possibly comma-space separated)
  • It will include single problems in the form of just a number (e.g. 79)
  • And ranges in the form 17-18 (again, you have to deal with optional spaces)
  • The ranges are inclusive of both ends
  • The ranges will optionally be suffixed by odd or even, which you have to take into account.
  • A set of ranges/pages will be prepended by a page number in the form pg. 545: , again having to deal with optional spaces. You can safely ignore these, as you need to get the problems over all the pages
  • The text may be in uppercase or lowercase, but will not be both.
  • Return, stdout, etc. the number of problems I have to do for homework.
  • Since this is , shortest code in bytes wins!

##Test Cases

pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even   ->    27
pg. 34: 1                                                    ->    1
PG. 565: 2-5,PG.345:7                                        ->    5
pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80                ->    70
pg.492: 2-4 odd,7-9 even                                     ->    2

My teacher always gives me the most complicated set of math problems for homework. Like: pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even. And I want to know in advance how much time to set aside for my homework, but I don't want to have to figure all that out. That's why its your task to program it for me.

Specifications

  • You will get a string detailing the problems that I have to complete as args, stdio, etc.
  • They will be comma separated (possibly comma-space separated)
  • It will include single problems in the form of just a number (e.g. 79)
  • And ranges in the form 17-18 (again, you have to deal with optional spaces)
  • The ranges are inclusive of both ends
  • The ranges will optionally be suffixed by odd or even, which you have to take into account.
  • A set of ranges/pages will be prepended by a page number in the form pg. 545: , again having to deal with optional spaces. You can safely ignore these, as you need to get the problems over all the pages
  • The text may be in uppercase or lowercase, but will not be both.
  • Return, stdout, etc. the number of problems I have to do for homework.
  • Since this is , shortest code in bytes wins!

Test Cases

pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even   ->    27
pg. 34: 1                                                    ->    1
PG. 565: 2-5,PG.345:7                                        ->    5
pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80                ->    70
pg.492: 2-4 odd,7-9 even                                     ->    2
Tweeted twitter.com/#!/StackCodeGolf/status/607286976522395649

My teacher always gives me the most complicated set of math problems for homework. Like: pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even. And I want to know in advance how much time to set aside for my homework, but I don't want to have to figure all that out. That's why its your task to program it for me.

##Specifications

  • You will get a string detailing the problems that I have to complete as args, stdio, etc.
  • They will be comma separated (possibly comma-space separated)
  • It will include single problems in the form of just a number (e.g. 79)
  • And ranges in the form 17-18 (again, you have to deal with optional spaces)
  • The ranges are inclusive of both ends
  • The ranges will optionally be suffixed by odd or even, which you have to take into account.
  • A set of ranges/pages will be prepended by a page number in the form pg. 545: , again having to deal with optional spaces. You can safely ignore these, as you need to get the problems over all the pages
  • The text may be in uppercase or lowercase, but will not be both.
  • Return, stdout, etc. the number of problems I have to do for homework.
  • Since this is , shortest code in bytes wins!

##Test Cases

pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even   ->    27
pg. 34: 1                                                    ->    1
PG. 565: 2-5,PG.345:7                                        ->    5
pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80                ->    70
pg.492: 2-4 odd,7-9 even                                     ->    2

My teacher always gives me the most complicated set of math problems for homework. Like: pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even. And I want to know in advance how much time to set aside for my homework, but I don't want to have to figure all that out. That's why its your task to program it for me.

##Specifications

  • You will get a string detailing the problems that I have to complete as args, stdio, etc.
  • They will be comma separated (possibly comma-space separated)
  • It will include single problems in the form of just a number (e.g. 79)
  • And ranges in the form 17-18 (again, you have to deal with optional spaces)
  • The ranges are inclusive of both ends
  • The ranges will optionally be suffixed by odd or even, which you have to take into account.
  • A set of ranges/pages will be prepended by a page number in the form pg. 545: , again having to deal with optional spaces. You can safely ignore these, as you need to get the problems over all the pages
  • The text may be in uppercase or lowercase, but will not be both.
  • Return, stdout, etc. the number of problems I have to do for homework.
  • Since this is , shortest code in bytes wins!

##Test Cases

pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even   ->    27
pg. 34: 1                                                    ->    1
PG. 565: 2-5,PG.345:7                                        ->    5
pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80                ->    70
pg.492: 2-4 odd,7-9 even -> 2

My teacher always gives me the most complicated set of math problems for homework. Like: pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even. And I want to know in advance how much time to set aside for my homework, but I don't want to have to figure all that out. That's why its your task to program it for me.

##Specifications

  • You will get a string detailing the problems that I have to complete as args, stdio, etc.
  • They will be comma separated (possibly comma-space separated)
  • It will include single problems in the form of just a number (e.g. 79)
  • And ranges in the form 17-18 (again, you have to deal with optional spaces)
  • The ranges are inclusive of both ends
  • The ranges will optionally be suffixed by odd or even, which you have to take into account.
  • A set of ranges/pages will be prepended by a page number in the form pg. 545: , again having to deal with optional spaces. You can safely ignore these, as you need to get the problems over all the pages
  • The text may be in uppercase or lowercase, but will not be both.
  • Return, stdout, etc. the number of problems I have to do for homework.
  • Since this is , shortest code in bytes wins!

##Test Cases

pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even   ->    27
pg. 34: 1                                                    ->    1
PG. 565: 2-5,PG.345:7                                        ->    5
pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80                ->    70
pg.492: 2-4 odd,7-9 even                                     ->    2
added 34 characters in body
Source Link
Maltysen
  • 25.8k
  • 4
  • 55
  • 127

My teacher always gives me the most complicated set of math problems for homework. Like: pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even. And I want to know in advance how much time to set aside for my homework, but I don't want to have to figure all that out. That's why its your task to program it for me.

##Specifications

  • You will get a string detailing the problems that I have to complete as args, stdio, etc.
  • They will be comma separated (possibly comma-space separated)
  • It will include single problems in the form of just a number (e.g. 79)
  • And ranges in the form 17-18 (again, you have to deal with optional spaces)
  • The ranges are inclusive of both ends
  • The ranges will optionally be suffixed by odd or even, which you have to take into account.
  • A set of ranges/pages will be prepended by a page number in the form pg. 545: , again having to deal with optional spaces. You can safely ignore these, as you need to get the problems over all the pages
  • The text may be in uppercase or lowercase, but will not be both.
  • Return, stdout, etc. the number of problems I have to do for homework.
  • Since this is , shortest code in bytes wins!

##Test Cases

pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even   ->    27
pg. 34: 1                                                    ->    1
PG. 565: 2-5,PG.345:7                                        ->    5
pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80                ->    70
pg.492: 2-4 odd,7-9 even -> 2

My teacher always gives me the most complicated set of math problems for homework. Like: pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even. And I want to know in advance how much time to set aside for my homework, but I don't want to have to figure all that out. That's why its your task to program it for me.

##Specifications

  • You will get a string detailing the problems that I have to complete as args, stdio, etc.
  • They will be comma separated (possibly comma-space separated)
  • It will include single problems in the form of just a number (e.g. 79)
  • And ranges in the form 17-18 (again, you have to deal with optional spaces)
  • The ranges are inclusive of both ends
  • The ranges will optionally be suffixed by odd or even, which you have to take into account.
  • A set of ranges/pages will be prepended by a page number in the form pg. 545: , again having to deal with optional spaces. You can safely ignore these, as you need to get the problems over all the pages
  • The text may be in uppercase or lowercase, but will not be both.
  • Return, stdout, etc. the number of problems I have to do for homework.
  • Since this is , shortest code in bytes wins!

##Test Cases

pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even   ->    27
pg. 34: 1                                                    ->    1
PG. 565: 2-5,PG.345:7                                        ->    5
pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80                ->    70 

My teacher always gives me the most complicated set of math problems for homework. Like: pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even. And I want to know in advance how much time to set aside for my homework, but I don't want to have to figure all that out. That's why its your task to program it for me.

##Specifications

  • You will get a string detailing the problems that I have to complete as args, stdio, etc.
  • They will be comma separated (possibly comma-space separated)
  • It will include single problems in the form of just a number (e.g. 79)
  • And ranges in the form 17-18 (again, you have to deal with optional spaces)
  • The ranges are inclusive of both ends
  • The ranges will optionally be suffixed by odd or even, which you have to take into account.
  • A set of ranges/pages will be prepended by a page number in the form pg. 545: , again having to deal with optional spaces. You can safely ignore these, as you need to get the problems over all the pages
  • The text may be in uppercase or lowercase, but will not be both.
  • Return, stdout, etc. the number of problems I have to do for homework.
  • Since this is , shortest code in bytes wins!

##Test Cases

pg. 546: 17-19, 22, 26, pg. 548: 35-67 odd, 79, 80-86 even   ->    27
pg. 34: 1                                                    ->    1
PG. 565: 2-5,PG.345:7                                        ->    5
pg. 343: 5,8,13 - 56 even,pg. 345: 34 - 78,80                ->    70
pg.492: 2-4 odd,7-9 even -> 2
Fixed minor typo
Source Link
Alex A.
  • 24.7k
  • 5
  • 38
  • 119
Loading
Source Link
Maltysen
  • 25.8k
  • 4
  • 55
  • 127
Loading