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

1 of 3
Sanchises
  • 9.5k
  • 1
  • 37
  • 63

MATL, 15 bytes

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

Try it online!

I've added a simple 'if/else' statement in the TIO link, for those who don't believe that a single 0 makes an array falsey in MATL.

Explanation:

 G" ] % Main 'for' loop, to loop over input G
 @V % Push current number, convert to string
 X& % Intersect with stringified number already on the stack.
 n % Count the size of the intersection
 v@ % Push the stringified number for the intersection in the next loop. 
1)V % For the first iteration, the first element of the input is stringified
 % (guaranteed not to have an empty intersection)
Sanchises
  • 9.5k
  • 1
  • 37
  • 63

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