# Scrambled PIN Tetris Puzzle

A quick story to explain the concept:

### Mexico

One day while out on a scooter I got caught out in the rain, and when I went to plug in my phone I shorted the screen- the port had water in it. I replaced the screen but lost the fingerprint reader functionality in the process. To unlock my phone anymore I had to use a pin, and after unlocking the phone over and over my screen was developing smudges in place of the PIN numbers. ~~Android~~ GrapheneOS has a function to “Scramble PIN input layout” within the Security tab of the Settings app, directly addressing my smudging problem. After a bajillion scrambles of my PIN pattern making various Tetris-shapes, I started to wonder, how often does this happen?

### What defines a Tetris-shape?

By Tetris-shape I mean tetromino. “A tetromino is a geometric shape composed of four squares, connected orthogonally” - Wikipedia. Shapes could be translated and/or rotated, I considered any orientation of the shape what would fit on the number pad. *If I counted correctly*, there are 42 cases where a 4 digit number creates a shape.

*I did not include rotations of the square. Square is Square

## Solution

Let’s get a baseline. To make a shape you need 4 *different* numbers. If any repeat you couldn’t make the 4th square. That said, there are 10 x 9 x 8 x 7 (*10P4*), or 5,040 possible non-repeating PIN numbers. This is an important assumption.

Since each shape is a set of 4 numbers, there are 4! or 24 possible permutations of that set that can create that shape. If we consider the other 42 orientations, there are 42*4! or 1,008 sets of 4 numbers that can create a tetromino.

Using some rough maths, we can say there’s ~1/5 (20%) chance that a PIN creates a Tetrino.