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.0.8.51 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.50 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.49 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.48 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.47 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.46 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.45 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.44 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.43 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.42 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.41 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.40 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.39 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.38 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.37 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.36 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.35 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.34 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.33 tracks/scala/exercises/hamming/example.scala
trackler-2.0.8.32 tracks/scala/exercises/hamming/example.scala