scala solution
scala\nobject Solution {\n  def findLexSmallestString(s: String, a: Int, b: Int): String = {\n    lazy val (gcd,gcd10) = ((BigInt(s.length) gcd b).toInt, BigInt
```scala\nobject Solution {\n  def findLexSmallestString(s: String, a: Int, b: Int): String = {\n    lazy val (gcd,gcd10) = ((BigInt(s.length) gcd b).toInt, BigInt(a) gcd 10)\n    lazy val (es,os) = s.toSeq.sliding(2,2).map(l => l.head -> l.last).toList.unzip\n    lazy val e1 = (gcd10 to 10 by gcd10)\n      .map{shift => es.map(c => (((c - \'0\' + shift) % 10 ) + \'0\').toChar)}\n    lazy val o1 = (gcd10 to 10 by gcd10)\n      .map{shift => os.map(c => (((c - \'0\' + shift) % 10 ) + \'0\').toChar)}\n    lazy val x0 =  (gcd10 to 10 by gcd10) map {shift =>\n      s.zipWithIndex.map{case (c,i) =>\n        (((c - \'0\' + (shift * (i&1))) % 10 ) + \'0\').toChar\n      }.mkString\n    }\n    lazy val x3 = (for {e<-e1; o<-o1} yield {(e zip o).map{case (a,b) => Seq(a,b)}})\n      .map(_.flatten.mkString)\n    (if(gcd%2 == 0) x0 else x3).flatMap{s1 =>\n      (s1 + s1).toSeq.sliding(s.length,gcd).map(_.unwrap)\n    }.min\n  }\n}\n```
['Enumeration', 'Scala']