Memes

Just this past fall, Facebook’s own Mark Zuckerberg joined Harvard Memes for Elitist 1% Tweens, a Facebook group in which Harvard students share memes, not unlike Yale Memes for Special Snowflake Teens, in which Yale students share the same:

wonderful

Asked in a comment where Bill Gates (a fellow dropout) was, Mark replied with a comment wherein Bill’s name was automatically hyperlinked to Bill’s own Facebook page:

billg

Answer the below in memes.md and memes.html.

Questions

  1. (3 points.) Not only can members comment on posts in a Facebook group they can also reply to other members' comments, just as Mark did, as is implied by his comment’s indentation. Suppose that Facebook stores those comments in a SQL database in some table. What are three fields (i.e., columns) that the table would seem to have? No need to mention their types.

  2. (2 points.) How might Facebook, in its SQL database, be associating replies with the comments to which they belong?

  3. (6 points.) Complete the implementation of linkify in memes.html in such a way that, given a string, s, the function returns a copy of s wherein every occurrence of any friend’s name (not username) has been replaced with a link to that friend’s Facebook page. (You’ll then find that the form in memes.html behaves quite like Facebook itself!) For instance, if s were:

    Hold on let me get him Bill Gates

    then linkify would return:

    Hold on let me get him <a href="https://www.facebook.com/BillGates">Bill Gates</a>

    Assume that all friends are accessible in FRIENDS, a global object wherein keys are friends' names and values are friends' usernames; do not assume that FRIENDS will contain only Bill and Mark. Assume that the URL of a page starts with https://www.facebook.com/ and ends with a friend’s username, a la Bill’s own. Do not assume that s will contain only one friend’s name, but do assume that each friend’s name will appear only once or not at all. No need to tokenize s; it suffices to find and replace each friend’s name in s, in any order, even if it happens to be (nonsensically) a substring of some other name or words. And it suffices to match friends' names case-sensitively: if Bill Gates is a key in FRIENDS, you need only match Bill Gates, not bill gates, in s.

Debrief

  1. Which resources, if any, did you find helpful in answering this problem’s questions?

  2. About how long, in minutes, did you spend on this problem’s questions?