MATL, 14 bytes
1&)"V@VX&nv@]x
Thanks @LuisMendo for saving a byte. Explanation:
1&) % Implicitly take input. 'Pop' the first item from the input on the stack.
" ] % Main 'for' loop, to loop over the rest of the input.
V % Stringify previous (or first) iten from the input.
@V % Push current number, convert to string
X& % Intersect with stringified number already on the stack.
n % Count the size of the intersection
@ % Push the current number again for the intersection in the next loop.
Sanchises
- 9.5k
- 1
- 37
- 63