Company: Quince_8thaug
Difficulty: medium
Variable Renaming Detection Every so often somebody tries to pass off a copied program as their own. The usual trick is to open the file in a text editor and use "Find and replace" on a variable name: every occurrence of some name A becomes some other name B . The trick can be repeated as often as the cheat likes, with different names each time. You are given two code snippets, code1 and code2 , each as a list of lines. Decide whether code2 could have been produced from code1 by a sequence of zero or more such renamings. For this problem a name is a maximal run of letters, digits and underscores that starts with a letter or an underscore. Everything else — spaces, punctuation, operators, digits that do not sit inside a name, and the line breaks themselves — is ordinary text. The problem draws no distinction between a variable and a keyword: if , return and def are names just like a and total . So code2 can be reached from code1 exactly when both of the following hold: The ordinary text