Fix Python – heapq with custom compare predicate

I am trying to build a heap with a custom sort predicate. Since the values going into it are of “user-defined” type, I cannot modify their built-in comparison predicate.
Is there a way to do something like:
h = heapq.heapify([…], key=my_lt_pred)
h = heapq.heappush(h, key=my_lt_pred)

Or even better, I could wrap the heapq functions in my own con….

Fix Python – Given a string of a million numbers, return all repeating 3 digit numbers

I had an interview with a hedge fund company in New York a few months ago and unfortunately, I did not get the internship offer as a data/software engineer. (They also asked the solution to be in Python.)
I pretty much screwed up on the first interview problem…

Question: Given a string of a million numbers (Pi for example), write
a function/p….

Fix Python – How to split text without spaces into list of words

Input: “tableapplechairtablecupboard…” many words
What would be an efficient algorithm to split such text to the list of words and get:
Output: [“table”, “apple”, “chair”, “table”, [“cupboard”, [“cup”, “board”]], …]
First thing that cames to mind is to go through all possible words (starting with first letter) and find the longest word pos….

Fix Python – How to check whether two lists are circularly identical in Python

For instance, I have lists:
a[0] = [1, 1, 1, 0, 0]
a[1] = [1, 1, 0, 0, 1]
a[2] = [0, 1, 1, 1, 0]
# and so on

They seem to be different, but if it is supposed that the start and the end are connected, then they are circularly identical.
The problem is, each list which I have has a length of 55 and contains only three ones and 52 zeros in it. Witho….