Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from toGraphWorker import graph
- Colors = [1, 2, 3, 4]
- Max_pow = 0
- Min_pow = 0
- def sorter(dict):
- new_dict = {}
- pows = []
- for i in dict:
- pows.append(len(dict[i]))
- pows.sort(reverse=True)
- global Max_pow
- Max_pow = pows[0]
- global Min_pow
- Min_pow = pows[len(pows) - 1]
- for i in pows:
- for j in dict:
- if len(dict[j]) == i:
- new_dict[j] = []
- new_dict[j].append(dict[j])
- return new_dict
- def solving(dict_of_country):
- color = 0
- countries_with_colors = {}
- current_countries = []
- name = ''
- name_of_last = ''
- pow_of_country = Max_pow
- for c in range(len(dict_of_country)):
- countries_with_colors[c] = set()
- for i in dict_of_country:
- countries_with_colors[0].add(i)
- if len(dict_of_country[i][0]) == Max_pow:
- color = 1
- if len(countries_with_colors[color])==0:
- countries_with_colors[color].add(i)
- elif len(dict_of_country[i][0]) == Min_pow:
- name_of_last = i
- print(countries_with_colors[0])
- while len(countries_with_colors[0]) != 0:
- for i in dict_of_country:
- if i in countries_with_colors[0] and countries_with_colors[color].isdisjoint(dict_of_country[i][0]):
- countries_with_colors[color].add(i)
- color += 1
- return countries_with_colors
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement