There are 2 files (logs): one reference, the other source. The files are line by line the paths to all files in the entire history of the repository. All lines of each file are unordered. The task is to compare the original log with the reference one to search for the corresponding line, and, if no match is found, output the excluded line line by line to a new file.

The task is incredibly easy, but I always experience the problem of lack of memory when solving the problem head-on with a recursive for loop, or there is a strange error that at some point they try to take a non-existent element from the list (I still do not know how to control and debug recursion)

How to solve this problem using a minimum of recursion?

    1 answer 1

    Why do you need recursion at all if you can use sets?

    f1 = ["aaa", "bbb", "ccc"] f2 = ["aaa", "bbb", "ddd", "ccc"] print(set(f2)-set(f1)) #{'ddd'} 

    Of course, there may be reasonable restrictions on the amount of information processed, but it’s worth a try.