Question: Whilst applying the below function I have bool values converted to integers.

What am I missing?

```
import pandas as pd

def multi(x):
    if isinstance(x, (float, int)):
        return x * 10
    return x

print(pd.DataFrame(data={"a": [True, False]}).applymap(func=multi))

```

Ouput:

```
    a
0  10
1   0

```

Expected:

```
       a
0   True
1   False

```

Answer: 
The regex looks at 11 characters because `board` has been joined with two extra `-` characters:

```
board = board.join('-')

```

Presumably, the original `board` is a 2D array, and the commas introduced by this join (as the nested arrays are stringified in the process), are removed with:

```
.replace(/,/g,'');

```

So an original board like this:

```
[
    [1, 0, 1],
    [2, 2, 0],
    [0, 0, 0]
]

```

...is turned into a string with `.join("-")`:

```
"1,0,1-2,2,0-0,0,0"

```

...and finally cleaned of the commas:

```
"101-220-000".

```

The additional separator makes it easier to find some patterns without raising false positives. For instance, when there is a match with `222`, one can be sure that they will be in one row, and a match with `1..1..1` will likewise detect the three possible vertical 3-in-a-rows without false positives as it can only have a match that starts at position 0, 1 or 2. The `1....1....1` is 11 characters long and can only match at position 0 for one of the diagonals. Finally, `1..1..1` can also only match at one position, i.e. position 2, as otherwise one of the hyphens would conflict with a `1` in the pattern. A match represents the opposite diagonal.

### Further improvement

One could merge two regexes into one (saving some execution time), by using a back reference, and use some logic to join all possibilities in one expression:

```
function isSolved(board) {
   board = board.join('-').replace(/,/g,'');
   var match = board.search(/([12])(\1|...\1...|....\1....|..\1..)\1/);
   return +(board[match] || board.includes("0") && -1);
}

```
After the `join` and `replace` operations, `board` will be a string like this:

```
001-012-210

```

Each row is separated by `-`.

The `111` case is testing for a row full of X's.

The `1...1...1` case is testing for a column full of X's. There are 3 dots because there is also the `-` character.

The `1..1..1` case is testing for a diagonal full of X's.