Sha256: f00ab50d1a5ec887e6e753235f535b79441eb6e782a643eb6a2f1db6f2bc3189
Contents?: true
Size: 570 Bytes
Versions: 54
Compression:
Stored size: 570 Bytes
Contents
use "collections" class Hamming let _name: String new create() => _name = "Hamming" fun apply(strand1: String, strand2: String): U8 ? => if (strand1.size() != strand2.size()) then error end compute_distance(strand1, strand2) fun compute_distance(strand1: String, strand2: String): U8 ? => let size: USize = strand1.size() var dist: U8 = U8(0) var idx: ISize = 0 while idx < size.isize() do if (strand1.at_offset(idx).ne(strand2.at_offset(idx))) then dist = dist + 1 end idx = idx + 1 end dist
Version data entries
54 entries across 54 versions & 1 rubygems