Skip to main content
added 1 character in body
Source Link
Dr Y Wit
  • 601
  • 3
  • 4

Scala, 9280 bytes

def^(s:String)="s=>"(.)\\1*".r.findAllIn(s).map(_.size).reduce((x,y)=>(BigInt(x) gcd y).toInt)>1

Try it online!Try it online!

PS. Original solution was based on split function but it's longer (9583 bytes).

def^(s:String)=s=>(s+s).split("(.)(?!\\1)").map(_.size+1).reduce((x,y)=>(BigInt(x) gcd y).toInt)>1

Scala, 92 bytes

def^(s:String)="(.)\\1*".r.findAllIn(s).map(_.size).reduce((x,y)=>(BigInt(x) gcd y).toInt)>1

Try it online!

PS. Original solution was based on split function but it's longer (95 bytes).

def^(s:String)=(s+s).split("(.)(?!\\1)").map(_.size+1).reduce((x,y)=>(BigInt(x) gcd y).toInt)>1

Scala, 80 bytes

s=>"(.)\\1*".r.findAllIn(s).map(_.size).reduce((x,y)=>(BigInt(x) gcd y).toInt)>1

Try it online!

PS. Original solution was based on split function but it's longer (83 bytes).

s=>(s+s).split("(.)(?!\\1)").map(_.size+1).reduce((x,y)=>(BigInt(x) gcd y).toInt)>1
added 454 characters in body
Source Link
Dr Y Wit
  • 601
  • 3
  • 4

Scala, 7292 bytes

def^(s:String)="(.)\\1*".r.findAllIn(s).map(_.size).reduce((x,y)=>(BigInt(x) gcd y).toInt)>1

Try it online!

PS. Original solution was based on split function but it's longer (95 bytes).

def^(s:String)=(s+s).split(""""(.)(?!\1\\1)"""").map(_.sizesize+1).distinctreduce((x,y)=>(BigInt(x) gcd y).size==1toInt)>1

Try it online!

Scala, 72 bytes

def^(s:String)=(s+s).split("""(.)(?!\1)""").map(_.size).distinct.size==1

Try it online!

Scala, 92 bytes

def^(s:String)="(.)\\1*".r.findAllIn(s).map(_.size).reduce((x,y)=>(BigInt(x) gcd y).toInt)>1

Try it online!

PS. Original solution was based on split function but it's longer (95 bytes).

def^(s:String)=(s+s).split("(.)(?!\\1)").map(_.size+1).reduce((x,y)=>(BigInt(x) gcd y).toInt)>1
added 8 characters in body
Source Link
Dr Y Wit
  • 601
  • 3
  • 4

Scala, 6872 bytes

def^(s:String)=s=(s+s).split("""(.)(?!\1)""").map(_.size).distinct.size==1

Try it online!Try it online!

Scala, 68 bytes

def^(s:String)=s.split("""(.)(?!\1)""").map(_.size).distinct.size==1

Try it online!

Scala, 72 bytes

def^(s:String)=(s+s).split("""(.)(?!\1)""").map(_.size).distinct.size==1

Try it online!

Source Link
Dr Y Wit
  • 601
  • 3
  • 4
Loading