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.2.1.180 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.179 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.178 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.177 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.176 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.175 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.174 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.173 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.172 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.171 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.170 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.169 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.167 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.166 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.165 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.164 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.163 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.162 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.161 tracks/typescript/exercises/hamming/hamming.example.ts
trackler-2.2.1.160 tracks/typescript/exercises/hamming/hamming.example.ts