Files
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

2.4 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
68f6587287ad1f4ad39b0c85 Challenge 99: Fingerprint Test 29 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--

is_match("helloworld", "helloworld") should return True.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_match("helloworld", "helloworld"), True)`)
}})

is_match("helloworld", "helloworlds") should return False.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_match("helloworld", "helloworlds"), False)`)
}})

is_match("helloworld", "jelloworld") should return True.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_match("helloworld", "jelloworld"), True)`)
}})

is_match("thequickbrownfoxjumpsoverthelazydog", "thequickbrownfoxjumpsoverthelazydog") should return True.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_match("thequickbrownfoxjumpsoverthelazydog", "thequickbrownfoxjumpsoverthelazydog"), True)`)
}})

is_match("theslickbrownfoxjumpsoverthelazydog", "thequickbrownfoxjumpsoverthehazydog") should return True.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_match("theslickbrownfoxjumpsoverthelazydog", "thequickbrownfoxjumpsoverthehazydog"), True)`)
}})

is_match("thequickbrownfoxjumpsoverthelazydog", "thequickbrownfoxjumpsoverthehazycat") should return False.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_match("thequickbrownfoxjumpsoverthelazydog", "thequickbrownfoxjumpsoverthehazycat"), False)`)
}})

--seed--

--seed-contents--

def is_match(fingerprint_a, fingerprint_b):

    return fingerprint_a

--solutions--

def is_match(fingerprint_a, fingerprint_b):
    if len(fingerprint_a) != len(fingerprint_b):
        return False

    mismatches = 0

    for c1, c2 in zip(fingerprint_a, fingerprint_b):
        if c1 != c2:
            mismatches += 1
            if mismatches > len(fingerprint_a) // 10:
                return False

    return True