Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
recursion solution in Clear category for Adjacent Letters by kurosawa4434
from re import sub, search
reg = r'(.)\1'
def adjacent_letters(line: str) -> str:
return line if not search(reg, line) else adjacent_letters(sub(reg, '', line))
print("Example:")
print(adjacent_letters("abbaca"))
assert adjacent_letters("adjacent_letters") == "adjacent_lrs"
assert adjacent_letters("") == ""
assert adjacent_letters("aaa") == "a"
assert adjacent_letters("ABBA") == ""
print("The mission is done! Click 'Check Solution' to earn rewards!")
Sept. 12, 2022
Comments: