Skip to content

Instantly share code, notes, and snippets.

@7c00
Last active January 1, 2016 14:34
Show Gist options
  • Save 7c00/9216518c4e7c35b296b8 to your computer and use it in GitHub Desktop.
Save 7c00/9216518c4e7c35b296b8 to your computer and use it in GitHub Desktop.
import itertools
def parse_ip(ip):
rans = map(lambda x: range(x[0], x[-1] + 1),
[map(int, part.split('-')) for part in ip.split('.')])
return ['.'.join(map(str, i)) for i in itertools.product(*rans)]
if __name__ == '__main__':
print('\n'.join(parse_ip('192.168.1-2.1-10')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment