This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"icb": "0001", | |
"supersectors": [ | |
{ | |
"icb": "0500", | |
"name": "Oil & Gas", | |
"sectors": [ | |
{ | |
"icb": "0530", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
def combine_ranges(ranges, are_touching=lambda x, y: y - x == 1): | |
""" | |
Create new list of ranges combining ranges if they overlap | |
or touch each other. | |
Examples using integers: | |
>>> combine_ranges(((1,5), (3,7))) |