Problem 3. Duplicated Substrings
A substring is a contiguous sequence of characters from a string. For example, "cde" is a substring of the string "abcdefg". We say that substring s1 is duplicated in string s if s1 appears in s at least two times, without overlapping. For example, if s = "abcdefbcdgh" then there is a duplicated substring of length 3: "bcd". There is no duplicated substring in s of length 4 and higher.
a) Write in file p3_....py a function find_dup_str(s, n) that determines whether a string s contains a duplicated substring of a given length n and that returns the first occurring substring of length n that is duplicated (if any) or the empty string, otherwise. For the example above (s == "abcdefbcdgh") with substring length 3, the substring to be returned is "bcd". With length 2, the algorithm returns "bc" and not "cd". For this value of parameter s, if the length parameter is 4 or more, the algorithm returns an empty string. Your solution must use string slicing and must not use the str function.
Write after the function definition some code that reads a string and a number from the terminal, and then calls find_dup_str(s, n) and prints the result. Use this for testing.
b) Write in file p3_....py a function find_max_dup(s) that takes a string s as a parameter and that determines the longest substring that is duplicated in s. For instance, find_max_dup("abcdefbcdgh") the function should return "bcd". If the string s has no duplicated substrings, then the algorithm should return an empty string, e.g. find_max_dup("0123456") should return an empty string. This function MUST use the code written for part a), i.e. must make calls to find_dup_str(...) and use its result.
Write after the function definition code that reads a string from the terminal in variable s and then calls find_max_dup(s) and prints the result.