Question: Quick please! A 148-code of length n is a string of n characters where each character is 1, 4, or 8. Moreover, a valid 148-code
Quick please!

A "148-code" of length n is a string of n characters where each character is "1", "4", or "8". Moreover, a valid 148-code does NOT contain consecutive 8's. For example, "1848" is a valid 148-code, but "1884" is not valid. The empty string is a valid 148-code. Complete the following _recursive_ function that, given an integer n, returns a list of all valid 148-codes of length n (in any order). Estimated number of lines of code to write: about 10 to 15 lines. II II II from typing import List # No other import is allowed def generate_148_codes (n: int) -> List[str]: Returns a list of all valid 148-codes of length n Precondition: n >= 0 >>> generate_148_codes (0) [''] >>> generate_148_codes (2) ['11', '14', '18', '41', '44', '48', '81', '84'] TODO: complete this function below Hint: revisit the "binary codes" example in week 6's lecture if needed. You probably don't need a helper function, but you can add it if you want
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
