Станислав обнови решението на 20.03.2015 23:19 (преди над 9 години)
+def extract_type(elements, return_type):
+ result = ''
+ for element in elements:
+ if type(element[0]) is return_type:
+ result += str(element[0])*element[1]
+ return result
+
+
+def reversed_dict(elements):
+ result = {}
+ for key, value in elements.items():
+ result[value] = key
+ return result
+
+
+def flatten_dict(elements):
+ result = {}
+ for key, value in elements.items():
+ keys = ''
+ result.update(concat_keys(key, value, keys, result))
+ return result
+
+
+def concat_keys(key, value, keys, result):
+ keys += key
+ if type(value) is dict:
+ keys += '.'
+ temp_element = ''
+ for i_key, i_value in value.items():
+ temp_element = concat_keys(i_key, i_value, keys, result)
+ result.update(temp_element)
+ return temp_element
+ else:
+ return {keys: value}
+
+
+def reps(elements):
+
+ if type(elements) is tuple:
+ elements = list(elements)
+
+ remove_items = []
+ for element in elements:
+ if elements.count(element) == 1:
+ remove_items.append(element)
+
+ return tuple([item for item in elements if item not in remove_items])