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.0 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
68b1f72371a5ac895ac70a0a Challenge 44: String Mirror 29 challenge-44

--description--

Given two strings, determine if the second string is a mirror of the first.

  • A string is considered a mirror if it contains the same letters in reverse order.
  • Treat uppercase and lowercase letters as distinct.
  • Ignore all non-alphabetical characters.

--hints--

is_mirror("helloworld", "helloworld") should return False.

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

is_mirror("Hello World", "dlroW olleH") should return True.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_mirror("Hello World", "dlroW olleH"), True)`)
}})

is_mirror("RaceCar", "raCecaR") should return True.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_mirror("RaceCar", "raCecaR"), True)`)
}})

is_mirror("RaceCar", "RaceCar") should return False.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_mirror("RaceCar", "RaceCar"), False)`)
}})

is_mirror("Mirror", "rorrim") should return False.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_mirror("Mirror", "rorrim"), False)`)
}})

is_mirror("Hello World", "dlroW-olleH") should return True.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_mirror("Hello World", "dlroW-olleH"), True)`)
}})

is_mirror("Hello World", "!dlroW !olleH") should return True.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_mirror("Hello World", "!dlroW !olleH"), True)`)
}})

--seed--

--seed-contents--

def is_mirror(str1, str2):

    return str1

--solutions--

def is_mirror(str1, str2):
    clean1 = "".join(c for c in str1 if c.isalpha())
    clean2 = "".join(c for c in str2 if c.isalpha())
    return clean1[::-1] == clean2