June 10, 2019

I am making some progress on the second lab for 6.009. I have realized that my life will be MUCH MUCH easier if I can implement some helper functions to help with my get_actors_with_bacon_number function. Namely, these would be the functions which generate a dictionary mapping each actor to the actors they have acted with. The second helper function accepts as inputs the data set generated by the first helper function mapping each actor to the other actors they have acted with , the current set of actors, and the set of actors with bacon number i-1. Using these parameters, I devised an algorithm to generate the set of actors with bacon number i.

Utilizing both of these functions, I believe that we can find the actors with bacon number n by looping through the range(n) and at each iteration calling the second helper function, which returns the next set of actors with bacon number. Parameters here are acted_with generated by the first helper function, the current set of actors (Kevin Bacon), and the root from which all actors with the next bacon number are generated: a dictionary mapping 4724 (Kevin Bacon’s bacon number) to None – {4724:None}. I am still getting some testing errors when I run the test.py file in the lab, but I believe I have made somewhat of a breakthrough here. All that’s left for me is to fix the logical bugs in my code.

I spent the better part of 3 hours today on leetcode solving more problems. Namely, I finally did the integer to roman numeral converter, which was not that much harder than the reverse converter. The secret here was nesting a while loop inside of a for loop, which didn’t occur to me while I had tried this problem earlier. I did two mock interviews as well, the first one was actually incredibly easy for me and I did it in 15 minutes despite the allotted time of 90 minutes. The second one I guess I ‘failed’, as I was only able to solve one out of the two questions. I got hung up on the following question: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

For example, given n = 3, a solution set is:

[
  "((()))",
  "(()())",
  "(())()",
  "()(())",
  "()()()"
]

I’ll try to solve this tomorrow, I ran out of time in the mock interview (the first question took me ~30 minutes, and I only had ~30 minutes for this one which was sadly not enough time). Hopefully I can find a creative way to solve this tomorrow!