Sha256: 0165176357d16c56a767bfb561ce452d48ed1f2a385d47873a49fb6c5abaa95d

Contents?: true

Size: 371 Bytes

Versions: 191

Compression:

Stored size: 371 Bytes

Contents

class Hamming(strand1: String, strand2: String) {

  def distance =
    if (strand1.length == strand2.length) {
      val dist = commonPairs.count { case (a, b) => a != b }
      Some(dist)
    } else None

  private def commonPairs = strand1.zip(strand2)
}

object Hamming {
  def compute(strand1: String, strand2: String) =
    new Hamming(strand1, strand2).distance
}

Version data entries

191 entries across 191 versions & 1 rubygems

Version Path
trackler-2.1.0.36 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.34 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.33 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.32 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.31 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.30 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.29 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.28 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.27 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.26 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.25 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.24 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.23 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.22 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.21 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.20 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.19 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.18 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.17 tracks/scala/exercises/hamming/example.scala
trackler-2.1.0.16 tracks/scala/exercises/hamming/example.scala