Симеон обнови решението на 23.03.2015 02:01 (преди над 9 години)
+from functools import reduce
+
+
+def extract_type(list_, type_):
+ result_as_array = [str(
+ elem[0])*elem[1] for elem in list_ if type(elem[0]) == type_]
+ return reduce(lambda a, b: a+b, result_as_array, '')
+
+
+def reversed_dict(dict_):
+ return dict(zip(dict_.values(), dict_.keys()))
+
+
+def flatten_dict(dict_):
+ return _flatten(dict_, [], {})
+
+
+def _flatten(dict_, nodes, result):
+ for key in dict_.keys():
+ node = '.'.join(nodes + [key])
+ if type(dict_[key]) is dict:
+ _flatten(dict_[key], nodes + [key], result)
+ else:
+ result[node] = dict_[key]
+ return result
+
+
+def unflatten_dict(dict_):
+ pass
+
+
+def reps(list_):
+ return tuple(filter(lambda elem: list_.count(elem) > 1,
+ list_))