This commit is contained in:
commit
568474d52f
1591 files changed
+528213
No files matched your search
@@ -0,0 +1,20 @@
|
||||
# probe: codepoint indexing, lower(), and early returns
|
||||
# status: the expected output is Programming+'s interpreter's prediction; corpus.py verify confirms or refutes it on godbolt
|
||||
# expect-stdout: Level True
|
||||
# expect-stdout: rotor True
|
||||
# expect-stdout: Mojo False
|
||||
# expect-stdout: a True
|
||||
# expect-stdout: True
|
||||
# expect-stdout: abBA True
|
||||
def is_palindrome(s: String) -> Bool:
|
||||
var t = s.lower()
|
||||
var n = t.count_codepoints()
|
||||
for i in range(n // 2):
|
||||
if String(t[codepoint=i]) != String(t[codepoint=n - 1 - i]):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
for w in ["Level", "rotor", "Mojo", "a", "", "abBA"]:
|
||||
print(w, is_palindrome(w))
|
||||
Reference in new issue
Block a user