Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import itertools
  2. import sys
  3.  
  4. def func(value):
  5. value_len = len(value)
  6. new_value = ''
  7. for i in range(value_len):
  8. if i == value_len - 1:
  9. new_value += value[i]
  10. else:
  11. new_value += value[i] + '-'
  12.  
  13. max_dots = value_len - 1
  14. indexes = []
  15. for i in range(max_dots):
  16. indexes.append(i * 2 + 1)
  17.  
  18. for i in range(max_dots):
  19. combinations = itertools.combinations(indexes, i + 1)
  20. for combination in combinations:
  21. output = new_value
  22. for index in indexes:
  23. if index in combination:
  24. output_list = list(output)
  25. output_list[index] = '.'
  26. output = ''.join(output_list)
  27. output = output.replace('-', '')
  28. print(output)
  29.  
  30. if len(sys.argv) == 2:
  31. string = sys.argv[1]
  32. if string.isalnum():
  33. func(string)
  34. else:
  35. print('Input must be alphanumeric')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement