#NEWLINE# def combination( array ) : #NEWLINE# #INDENT# if ( len ( array ) < 2 ) : #NEWLINE# #INDENT# return set ( array ) #NEWLINE# #UNINDENT# result = set ( ) #NEWLINE# for ( index , item ) in enumerate ( array ) : #NEWLINE# #INDENT# new_array = ( array [ : index ] + array [ ( index + 1 ) : ] ) #NEWLINE# result . add ( perm ) #NEWLINE# for perm in combination ( new_array ) : #NEWLINE# #INDENT# new_item = '' . join ( sorted ( ( item + perm ) ) ) #NEWLINE# result . add ( new_item ) #NEWLINE# #UNINDENT# #UNINDENT# return result