Виктория обнови решението на 22.03.2015 19:47 (преди над 9 години)
+def extract_type(list_of_symbols, value_type):
+ result = ''
+ for type_symbol, number_of_symbols in list_of_symbols:
+ if type(type_symbol) == value_type:
+ count = number_of_symbols
+ while count > 0:
+ result += str(type_symbol)
+ count -= 1
+ return result
+
+
+def reversed_dict(dictionary):
+ result = {}
+ for key in dictionary:
+ if result.get(key) is None:
+ result[dictionary[key]] = key
+ return result
+
+
+def reps(list_of_numbers):
+ result = []
+ for element in list_of_numbers:
+ if list_of_numbers.count(element) > 1:
+ result.append(element)
+ result = tuple(result)
+ return result
+
+
+def help_func(dictionary, check):
+ result = dictionary
+ if check is False:
+ result = flatten_dict(dictionary)
+ return result
+
+
+def flatten_dict(dictionary):
+ temp_result = {}
+ check = True
+ for key in dictionary:
+ if type(dictionary[key]) != dict:
+ temp_result[key] = dictionary[key]
+ else:
+ for second in dictionary[key]:
+ temp_str = key + '.' + second
+ temp_result[temp_str] = dictionary[key][second]
+ for k in temp_result:
+ if type(temp_result[k]) == dict:
+ check = False
+ return help_func(temp_result, check)