Юлия обнови решението на 23.03.2015 12:51 (преди над 9 години)
+def extract_type(input_data, searched_type):
+ result = list()
+ for element, count in input_data:
+ if type(element) == searched_type:
+ n_times = count
+ while n_times > 0:
+ result.append(element)
+ n_times -= 1
+ return ''.join(result)
+
+
+def reversed_dict(input_data):
+ result = {}
+ for key in input_data:
+ result[input_data[key]] = key
+ return result
+
+
+def flatten_dict_helper(help_key, input_data, result):
+ for key in input_data:
+ if help_key == '':
+ current_key = key
+ else:
+ current_key = help_key + '.' + key
+ if type(input_data[key]) == dict:
+ flatten_dict_helper(current_key, input_data[key], result)
+ else:
+ result[current_key] = input_data[key]
+
+
+def flatten_dict(input_data):
+ result = {}
+ flatten_dict_helper('', input_data, result)
+ return result
+
+
+def reps(input_data):
+ result = list()
+ for index, value in enumerate(input_data):
+ first_part = input_data[:index]
+ second_part = input_data[index+1:]
+ if first_part.count(value) != 0 or second_part.count(value) != 0:
+ result.append(value)
+ return tuple(result)