Гален обнови решението на 19.03.2015 23:17 (преди над 9 години)
+def extract_type ( list, type ):
+ result = ""
+
+ for item in list :
+ if isinstance ( item[0], type ):
+ result += str ( item[0] ) * item[1]
+
+ return result
+
+def reversed_dict ( dictionary ):
+ reversedDict = {}
+
+ for item in dictionary :
+ reversedDict[ dictionary[item] ] = item
+
+ return reversedDict
+
+def flatten ( dictionary, parentKey = '' ):
+ flattenDictionary = []
+
+ for key, value in dictionary.items():
+ newKey = key
+ if ( parentKey ):
+ newKey = parentKey + '.' + key
+
+ if isinstance ( value, dict ):
+ flattenDictionary.extend ( flatten ( value, newKey ).items() )
+ else:
+ flattenDictionary.append ( ( newKey, value ) )
+
+ return dict ( flattenDictionary )
+
+def unflatten_dict ( dictionary ):
+ unflattenDictionary = {}
+
+ for key, value in dictionary.items():
+ currentKey = key.split ( '.' )
+ tempDictionary = unflattenDictionary
+
+ for item in currentKey[:-1]:
+ if item not in tempDictionary:
+ tempDictionary[item] = {}
+ tempDictionary = tempDictionary[item]
+
+ tempDictionary[ currentKey[-1] ] = value
+
+ return unflattenDictionary
+
+def reps ( array ):
+ repArray = []
+ for item in array:
+ if array.count ( item ) > 1:
+ repArray.append ( item )
+
+ return repArray
- Пусни си примерните тестове
- Пусни
pep8
проверка, имаш доста неща за оправяне - Имената на променливите трябва да са в
snake_case
- Оставяш ненужни интервали около променливите