3
The Challenge
I always write my math assignments down in the same way. For example:
pg. 420: #25, 50-56, 90
pg. 26: #50-60 evens, 70-80 odds, 90-99 3s
pg. 69: #12, 16, 18, 37
But I need you to tell me the individual problem numbers. For example:
input:
pg. 420: #25, 50-56, 90
output:
25, 50, 51, 52, 53, 54, 55, 56, 90
Here are the rules for telling me my problem numbers:
The assignment always starts with pg. (number): #, feel free to discard it.
Each group of problems is separated by a comma, and different patterns mean different things.
A single number (4, 6, 7438, 698236) just means that one problem is in the assignment.
Two numbers with a dash between them means those two numbers and all integers between. For example, 1-6 would become 1, 2, 3, 4, 5, 6
If two numbers have a dash between them, then there's a word, there is a special rule for the numbers.
If the word is evens, then all even numbers between the two are included (1-6 evens -> 2, 4, 6).
If the word is odds, then all odd numbers between the two are included (1-6 odds -> 1, 3, 5).
If the word is 3s, then all numbers where n mod 3 = 0 between the two are included (1-6 3s -> 3, 6);
Test Examples: (inputs then outputs)
pg. 1: #1, 2, 3
1, 2, 3
pg. 82: #76, 84-87, 91, 94-100 evens, 103-112 3s
76, 84, 85, 86, 87, 91, 94, 96, 98, 100, 103, 106, 109, 112
pg. 9001: #9000-9002 odds
9001
This is code-golf, so your score is the number of bytes.
Would stuff like "every other odd/even" be a valid input? Or "every other problem"? – Conor O'Brien – 2015-10-19T22:15:21.040
@CᴏɴᴏʀO'Bʀɪᴇɴ Those wouldn't be valid input currently; do you think they should be? – DanTheMan – 2015-10-19T22:18:03.790
No, just wondering. – Conor O'Brien – 2015-10-19T23:18:09.770
3I feel like we've had this challenge before. – xnor – 2015-10-19T23:26:25.423
2
Closely related: Tell me how many math problems I have to do!
– Dennis – 2015-10-19T23:49:17.290@Dennis TBH, that's just straight up a duplicate. This question does not differ significantly enough IMO. – orlp – 2015-10-19T23:58:39.217