Generate a set of codes composed of six uppercase English characters, requiring at least two characters of same position are different between any two codes, how many codes can be generated at most?
such as
['AAAAAA','AAAABB','AAAACC'...]
I have tried exhausive the results, but the code is too slow, or how to optimize the code
arrs = []
totalLen = 0
def isValid(t):
for arr in arrs:
equalCount = 0
for i in range(0, len(arr)):
if arr[i] == t[i]:
if equalCount == len(arr) - 2:
return False
else:
equalCount += 1
return True
hex = 'Z'
for a in range(ord('A'), ord(hex) + 1):
for b in range(ord('A'), ord(hex) + 1):
for c in range(ord('A'), ord(hex) + 1):
for d in range(ord('A'), ord(hex) + 1):
for e in range(ord('A'), ord(hex) + 1):
for f in range(ord('A'), ord(hex) + 1):
t = [a, b, c, d, e, f]
if isValid(t):
arrs.append(t)
totalLen += 1
print(' ' + ''.join(chr(ch) for ch in t))
print(' ' + chr(a) + chr(b) + chr(c) + chr(d) + ' :' + str(len(arrs)))
print(chr(a) + chr(b) + chr(c) + ' :' + str(len(arrs)))
print(len(arrs))
```