Skip to main content
Rollback to Revision 2
Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, 94 9287 bytes

function(s,n=nchar(s),g=substring)if(n)g(s,d<-which(!duplicated(g(s,1:n,1:n))),c(d[-1]-1,n))

Try it online!Try it online!

Returns a (possibly empty) list of substrings.

Thanks to Michael M for saving 27 bytes!

R, 94 92 bytes

function(s,n=nchar(s),g=substring)if(n)g(s,d<-which(!duplicated(g(s,1:n,1:n))),c(d[-1]-1,n))

Try it online!

Returns a (possibly empty) list of substrings.

Thanks to Michael M for saving 2 bytes!

R, 94 87 bytes

function(s,n=nchar(s),g=substring)g(s,d<-which(!duplicated(g(s,1:n,1:n))),c(d[-1]-1,n))

Try it online!

Returns a (possibly empty) list of substrings.

Thanks to Michael M for saving 7 bytes!

added 27 characters in body
Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, 94 8792 bytes

function(s,n=nchar(s),g=substring)if(n)g(s,d<-which(!duplicated(g(s,1:n,1:n))),c(d[-1]-1,n))

Try it online!Try it online!

Returns a (possibly empty) list of substrings.

Thanks to Michael M for saving 72 bytes!

R, 94 87 bytes

function(s,n=nchar(s),g=substring)g(s,d<-which(!duplicated(g(s,1:n,1:n))),c(d[-1]-1,n))

Try it online!

Returns a (possibly empty) list of substrings.

Thanks to Michael M for saving 7 bytes!

R, 94 92 bytes

function(s,n=nchar(s),g=substring)if(n)g(s,d<-which(!duplicated(g(s,1:n,1:n))),c(d[-1]-1,n))

Try it online!

Returns a (possibly empty) list of substrings.

Thanks to Michael M for saving 2 bytes!

added 13 characters in body
Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, 9494 87 bytes

function(s,n=nchar(s))if(n,g=substring)substringg(s,d<-which(!duplicated(el(strsplitg(s,"")1:n,1:n))),c(d[-1]-1,n))

Try it online!Try it online!

Returns a (possibly empty) list of substrings.

Thanks to Michael M for saving 7 bytes!

R, 94 bytes

function(s,n=nchar(s))if(n)substring(s,d<-which(!duplicated(el(strsplit(s,"")))),c(d[-1]-1,n))

Try it online!

Returns a (possibly empty) list of substrings.

R, 94 87 bytes

function(s,n=nchar(s),g=substring)g(s,d<-which(!duplicated(g(s,1:n,1:n))),c(d[-1]-1,n))

Try it online!

Returns a (possibly empty) list of substrings.

Thanks to Michael M for saving 7 bytes!

Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105
Loading