Михаела обнови решението на 23.03.2015 16:49 (преди над 9 години)
+def extract_type(input_elements, input_type):
+ output_ = ''
+ for element, count in input_elements:
+ if type(element) is input_type:
+ for _ in range(count):
+ output_ += str(element)
+ return output_
+
+
+def reversed_dict(input_):
+ return {input_[key]: key for key in input_}
+
+
+def reps(input_):
+ return tuple(filter(lambda element: input_.count(element) > 1, input_))
+
+
+def flatten_dict(input_):
+ output_ = {}
+ for key, value in input_.items():
+ if isinstance(value, dict):
+ value = {key + '.' + key_: value_
+ for key_, value_ in value.items()}
+ output_.update(flatten_dict(value))
+ else:
+ output_[key] = value
+ return output_