Skip to content

Instantly share code, notes, and snippets.

@Sciss
Created October 31, 2021 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sciss/195e1992358fc6bf9a77f031b2a69e2a to your computer and use it in GitHub Desktop.
Save Sciss/195e1992358fc6bf9a77f031b2a69e2a to your computer and use it in GitHub Desktop.
val s = "978-3-9504622-3-"
val s0 = s.filter(_.isDigit)
val u = (s0 zip Iterator.continually(Seq(1, 3)).flatten).map { case (c, m) => c.toString.toInt * m } .sum
val v = u.roundUpTo(10)
val p = v - u // 4
s ++ p.toString // "978-3-9504622-3-4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment