Number of pairs with Pandigital Concatenation | Checks if a given is Pandigital ; digit i is not present thus not pandigital ; Returns number of pairs of strings resulting in Pandigital Concatenations ; iterate over all pair of strings ; Driver code
def isPanDigital ( s ) : NEW_LINE INDENT digits = [ False ] * 10 ; NEW_LINE for i in range ( 0 , len ( s ) ) : NEW_LINE INDENT digits [ int ( s [ i ] ) - int ( '0' ) ] = True NEW_LINE DEDENT for i in range ( 0 , 10 ) : NEW_LINE INDENT if ( digits [ i ] == False ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT def countPandigitalPairs ( v ) : NEW_LINE INDENT pairs = 0 NEW_LINE for i in range ( 0 , len ( v ) ) : NEW_LINE INDENT for j in range ( i + 1 , len ( v ) ) : NEW_LINE INDENT if ( isPanDigital ( v [ i ] + v [ j ] ) ) : NEW_LINE INDENT pairs = pairs + 1 NEW_LINE DEDENT DEDENT DEDENT return pairs NEW_LINE DEDENT v = [ "123567" , "098234" , "14765" , "19804" ] NEW_LINE print ( countPandigitalPairs ( v ) ) NEW_LINE