dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
2.0 KiB
2.0 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 68f6587287ad1f4ad39b0c85 | Challenge 99: Fingerprint Test | 28 | challenge-99 |
--description--
Given two strings representing fingerprints, determine if they are a match using the following rules:
- Each fingerprint will consist only of lowercase letters (
a-z). - Two fingerprints are considered a match if:
- They are the same length.
- The number of differing characters does not exceed 10% of the fingerprint length.
--hints--
isMatch("helloworld", "helloworld") should return true.
assert.isTrue(isMatch("helloworld", "helloworld"));
isMatch("helloworld", "helloworlds") should return false.
assert.isFalse(isMatch("helloworld", "helloworlds"));
isMatch("helloworld", "jelloworld") should return true.
assert.isTrue(isMatch("helloworld", "jelloworld"));
isMatch("thequickbrownfoxjumpsoverthelazydog", "thequickbrownfoxjumpsoverthelazydog") should return true.
assert.isTrue(isMatch("thequickbrownfoxjumpsoverthelazydog", "thequickbrownfoxjumpsoverthelazydog"));
isMatch("theslickbrownfoxjumpsoverthelazydog", "thequickbrownfoxjumpsoverthehazydog") should return true.
assert.isTrue(isMatch("theslickbrownfoxjumpsoverthelazydog", "thequickbrownfoxjumpsoverthehazydog"));
isMatch("thequickbrownfoxjumpsoverthelazydog", "thequickbrownfoxjumpsoverthehazycat") should return false.
assert.isFalse(isMatch("thequickbrownfoxjumpsoverthelazydog", "thequickbrownfoxjumpsoverthehazycat"));
--seed--
--seed-contents--
function isMatch(fingerprintA, fingerprintB) {
return fingerprintA;
}
--solutions--
function isMatch(fingerprintA, fingerprintB) {
if (fingerprintA.length !== fingerprintB.length) return false;
const length = fingerprintA.length;
let mismatches = 0;
for (let i = 0; i < length; i++) {
if (fingerprintA[i] !== fingerprintB[i]) {
mismatches++;
if (mismatches > length * 0.1) return false;
}
}
return true;
}