Question: This is an intro to computer science course, so please dont use anything fancy where I would get caught for plagiarism :) 2.10 nonrepetitive(s) -
This is an intro to computer science course, so please dont use anything fancy where I would get caught for plagiarism :)
2.10 nonrepetitive(s) - 5 points This may be quite a challenging question to solve. Slicing and remembering that you can ask if two strings (81-s2) are the same are key to a short solution to this problem A nonrepetitive word is a word that does not contain any subword twice in a row. Examples: ana is nonrepetitive borborygmus is not nonrepetitive, since it has subword, bor twice in a row abracadabra is nonrepetitive. repetitive is not nonrepetitive since subword ti is repeated twice in a row grammar is not nonrepetitive since subword m is repeated twice in a row gaga is not s nonrepetitive since subword ga is repeated twice in a row rambunctious is nonrepetitive abcab is nonrepetitive abacaba is nonrepetitive. zrtzghtghtghtq is not nonrepetitive since subword ght is repeated twice (in fact three times, but it is enough to find two repetitions to conclude that the word is not nonrepetitive) aa is not nonrepetitive since subword a is repeated twice zatabracabrac is not nonrepetitive since subword abrac is repeated twice in a row Write a function, called nonrepetitive, that has one parameter, s, where s is a string. The function returns True if s is nonrepetitive and False otherwise. >>nonrepetitive("") True >nonrepetitive("a") True >>nonrepetitive("zrtzghtghtghtq") False >>> nonrepetitive ("abcab") True >nonrepetitive("12341341") False >>> nonrepetitive("44") False
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
