changeset 355 | 6af6441034f9 |
354:5dc6c3673f9d | 355:6af6441034f9 |
---|---|
1 s = "1, 3-7, 12, 15, 18-21" |
|
2 answer = [] |
|
3 single = "answer.append( %s )" |
|
4 many = "answer.extend(range(%s))" |
|
5 COMMA = ',' |
|
6 MINUS = '-' |
|
7 for p in s.split(COMMA): |
|
8 if MINUS not in p: |
|
9 eval( single % (p) ) |
|
10 else: |
|
11 p = p.replace( MINUS, COMMA) + '+ 1 ' |
|
12 eval( many % (p) ) |
|
13 print answer |