Иван обнови решението на 23.03.2015 15:02 (преди над 9 години)
+def extract_type(zipped, type_):
+ if type_ == str:
+ sum_elem = ''
+ else:
+ sum_elem = 0
+ for element in zipped:
+ if isinstance(element[0], type_):
+ i = element[1]
+ while i > 0:
+ sum_elem += element[0]
+ i = i - 1
+ return sum_elem
+
+
+def reversed_dict(dictionary):
+ new_dict = {}
+ for key, value in dictionary.items():
+ if value not in new_dict:
+ new_dict[value] = key
+ return new_dict
+
+
+def flatten_dict(dictionary, level=''):
+ new_dict = {}
+ for key, value in dictionary.items():
+ if isinstance(value, dict):
+ new_dict.update(flatten_dict(value, level + key))
+ else:
+ new_dict['.'.join(level + key)] = value
+ return new_dict
+
+
+def reps(elements):
+ new_elements = []
+ for element in elements:
+ if(elements.count(element) > 1):
+ new_elements.append(element)
+ return tuple(new_elements)
+# Unflatten
Тествай extract_type
с други типове
След като видях чуждите решения сега разбрах колко зле гърми.