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
pajonk
  • 19.4k
  • 5
  • 29
  • 78

R, 116 bytes

pryr::f(for(i in 1:min(nchar(v))){t=c()
`if`(anyDuplicated(t<-substr(v,i,i)),"",{cat(paste(t,collapse=""))
break})})

Try it online!

Explanation:

This effectively truncates all stings in the vector v to the length of the shortest and iterates through subsequent indexes. Then checks whether there are any duplicates within chosen letters and if not, pastes them together and prints with cat. If all indexes return duplicated results, this prints empty string.
All wraped in an anonymous pryr function.

pajonk
  • 19.4k
  • 5
  • 29
  • 78

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