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.
- You will get a string detailing the problems that I have to complete as args, stdio, etc.
- They will be comma separated (possibly
- It will include single problems in the form of just a number (e.g.
- 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
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 code-golf, shortest code in bytes wins!
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