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.98 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.97 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.96 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.95 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.94 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.93 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.92 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.91 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.90 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.89 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.88 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.87 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.86 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.85 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.84 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.83 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.82 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.81 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.80 tracks/crystal/exercises/hamming/src/example.cr
trackler-2.2.1.79 tracks/crystal/exercises/hamming/src/example.cr