Sha256: 8ca600de92ed05316daf8496a01f50a3632b5cc3204e95d0aeb576e2bea34b87

Contents?: true

Size: 285 Bytes

Versions: 396

Compression:

Stored size: 285 Bytes

Contents

class Hamming
  def self.compute(strand1 : String, strand2 : String)
    if strand1.size == strand2.size
      strand1.chars.zip(strand2.chars).count { |chars| chars[0] != chars[1] }
    else
      raise ArgumentError.new(message = "Strands must be of equal length")
    end
  end
end

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.179 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.178 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.177 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.176 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.175 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.174 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.173 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.172 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.171 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.170 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.169 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.167 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.166 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.165 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.164 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.163 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.162 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.161 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.160 tracks/crystal/exercises/hamming/src/example.cr