Solution

ID: past-exam-of-the-mathematics-course-of-the-university-of-cambridge/2025/ii/paper-3/4f/b/solution

Use the same program as , replacing only its first line by a test for a final :
If the input ends in , the loop erases it and eventually appends output . Every other input, including the empty word, follows the loop and produces . This is the characteristic function of .

New to topics? Read the docs here!