Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Recursion solution in Clear category for Unix Match. Part 1 by twilyght
def unix_match(file: str, p: str) -> bool:
if not p and not file:
return True
elif p[0] == '?':
return len(file) and unix_match(file[1:], p[1:])
elif p[0] == '*':
if len(p) == 1:
return True
else:
return any(unix_match(file[i:], p[1:]) for i in range(1, len(file)))
else:
return file[0] == p[0] and unix_match(file[1:], p[1:])
May 29, 2020
Comments: