Note: The difficulty of this question is not in proportion to the grades assigned. Make sure you do the other questions first!
Write a program that receives as input a sequence of ones (1) and zeros (0). Any number that is not one or zero will end the program. For every input digit, there is an output digit. A one is output when the most recent input digit completes the pattern ``1101" (i.e., 1, then 1, then 0, and then 1 is input), otherwise a zero is output. Overlapping patterns are not recognized. An example sequence is shown below. The first input is at the left end.
Input: 0 0 1 0 1 1 0 1 1 0 1 0 1 1 0 1 0 0 ... Output: 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 ...
You should not do any fancy input and output formatting. Just read an input and output 1 or 0 with a simple put 1 or put 0 statement. Assume that all inputs will be integers.