Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

3 of 3
added 243 characters in body
Sanchises
  • 9.5k
  • 1
  • 37
  • 63

MATL, 14 bytes

1&)"V@VX&nv@]x

Try it online!

Thanks @LuisMendo for saving a byte. Explanation:

1&) % 'Pop' the first item from the input and push it 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.
 nv % Count the size of the intersection, and add it to the existing list of sizes.
 @ % Push the current number again for the intersection in the next loop. 
 x % Remove the number pushed by the last loop.
 % Else the program would end with the result on the second instead of the first position in the stack
Sanchises
  • 9.5k
  • 1
  • 37
  • 63

AltStyle によって変換されたページ (->オリジナル) /