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 Answer

golfed and fixed explanation
Source Link
pajonk
  • 19.4k
  • 5
  • 29
  • 78

R, (削除) 116 (削除ここまで) 107(削除) 107 (削除ここまで) 95 bytes

R+pryr

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

Try it online! Try it online!

base R

function(v)for(i in 1:min(nchar(v)))`if`(anyDuplicated(t<-substr(v,i,i)),0,{cat(paste(t,collapse="")sep="")
v=0})

Try it online! Try it online!

These two variants saving 9 bytes thanks to Giuseppe.

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 with break to halt the loop, or base R function zeroing the vector to break the loop.

R, (削除) 116 (削除ここまで) 107 bytes

R+pryr

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

Try it online!

base R

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

Try it online!

These two variants saving 9 bytes thanks to Giuseppe.

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.

R, (削除) 116 (削除ここまで) (削除) 107 (削除ここまで) 95 bytes

R+pryr

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

Try it online!

base R

function(v)for(i in 1:min(nchar(v)))`if`(anyDuplicated(t<-substr(v,i,i)),0,{cat(t,sep="")
v=0})

Try it online!

These two variants saving 9 bytes thanks to Giuseppe.

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 with break to halt the loop, or base R function zeroing the vector to break the loop.

https://codegolf.stackexchange.com/questions/164208/enklactify-these-strings/164241?noredirect=1#comment397559_164241
Source Link
pajonk
  • 19.4k
  • 5
  • 29
  • 78

R, 116(削除) 116 (削除ここまで) 107 bytes

R+pryr

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

Try it online!

base R

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

Try it online! Try it online!

These two variants saving 9 bytes thanks to Giuseppe .

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.

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.

R, (削除) 116 (削除ここまで) 107 bytes

R+pryr

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

Try it online!

base R

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

Try it online!

These two variants saving 9 bytes thanks to Giuseppe .

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.

Source Link
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.

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