Question: I have a settings form where users can update their info.

My validation code looks like

```
    $rules = array(
        'active'    => 'required',
        'email'     => 'email',
        'username'  => "required|alphaNum|unique:users,username,{{$id}}",
        'password'  => 'sometimes|min:3'
    );

```

`$id` contains the user id of the current user.

But I keep getting the `The username has already been taken.` error message when the `username` value is the current username of the user.

I also tried the line as `'username' => "required|alphaNum|unique:users,username,".$id,`

Answer: 
In normal mathematical terms, `'AA'` is **not** a **permutation** of `'ABCD'`. You may be looking for a Cartesian Product instead -- and `itertools` supports that, too. E.g:

```
>>> for x in it.product('ABC', repeat=len('ABC')): print(x)
('A', 'A', 'A')
('A', 'A', 'B')
('A', 'A', 'C')
('A', 'B', 'A')
('A', 'B', 'B')
('A', 'B', 'C')
('A', 'C', 'A')
('A', 'C', 'B')
('A', 'C', 'C')
('B', 'A', 'A')
('B', 'A', 'B')
('B', 'A', 'C')
('B', 'B', 'A')
('B', 'B', 'B')
('B', 'B', 'C')
('B', 'C', 'A')
('B', 'C', 'B')
('B', 'C', 'C')
('C', 'A', 'A')
('C', 'A', 'B')
('C', 'A', 'C')
('C', 'B', 'A')
('C', 'B', 'B')
('C', 'B', 'C')
('C', 'C', 'A')
('C', 'C', 'B')
('C', 'C', 'C')

```

Note that these definitely aren't permutations -- the number of permutations of 3 items is 3 factorial, i.e 6, while the number of these items in the cartesian product of 3 copies of the 3-items sequence is 3 to the third power, AKA 81. Quite a difference!-)
For anyone else looking for something similar, this is the code I wrote. Works fine.

```
import itertools

print ('')
characters = input('Characters to include: ')
length = input('Length of each combination: ')
filename = input('Name of list file: ')
print ('')

length = int(length)

f1 = open(filename, 'w')
for p in itertools.product(characters,repeat=length):
    f1.write(''.join(str(x) for x in p) + '\n')
f1.close()

```