Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Using zip_longest solution in Clear category for One Switch Strings by U.V
from itertools import zip_longest
def switch_strings(line: str, result: str) -> bool:
s= ([[i,j] for i,j in zip_longest(line,result) if i!=j])
return len(s)==0 or (len (s) ==2 and s[0] == s[1][::-1])
print("Example:")
print(switch_strings("btry", "byrt"))
assert switch_strings("btry", "byrt") == True
assert switch_strings("boss", "boss") == True
assert switch_strings("solid", "disel") == False
assert switch_strings("false", "flaes") == False
assert switch_strings("true", "treu") == True
print("The mission is done! Click 'Check Solution' to earn rewards!")
Nov. 4, 2022
Comments: