Sha256: c1773ddf36d6973181b598ba152ab8928379730ea23d11a94c8ed99a87090b05

Contents?: true

Size: 534 Bytes

Versions: 295

Compression:

Stored size: 534 Bytes

Contents

class Hamming {
    compute(left: string, right: string): number {
        if (left.length !== right.length) {
            throw new Error('DNA strands must be of equal length.')
        }
        const size = left.length
        const leftArray = left.split("")
        const rightArray = right.split("")
        let count = 0
        for (let i: number = 0; i < size; i += 1) {
            if (leftArray[i] !== rightArray[i] ) {
                count += 1
            }
        }
        return count
    }
}

export default Hamming

Version data entries

295 entries across 295 versions & 1 rubygems

Version Path
trackler-2.1.0.0 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.55 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.54 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.53 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.52 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.51 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.50 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.49 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.48 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.47 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.46 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.45 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.44 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.43 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.42 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.41 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.40 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.39 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.38 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.0.8.37 tracks/typescript/exercises/hamming/hamming.example.ts