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:
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:
Answer the below in memes.md
and memes.html
.
Questions
-
(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 points.) How might Facebook, in its SQL database, be associating replies with the comments to which they belong?
-
(6 points.) Complete the implementation of
linkify
inmemes.html
in such a way that, given a string,s
, the function returns a copy ofs
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 theform
inmemes.html
behaves quite like Facebook itself!) For instance, ifs
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 thatFRIENDS
will contain only Bill and Mark. Assume that the URL of a page starts withhttps://www.facebook.com/
and ends with a friend’s username, a la Bill’s own. Do not assume thats
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 tokenizes
; it suffices to find and replace each friend’s name ins
, 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: ifBill Gates
is a key inFRIENDS
, you need only matchBill Gates
, notbill gates
, ins
.
Debrief
-
Which resources, if any, did you find helpful in answering this problem’s questions?
-
About how long, in minutes, did you spend on this problem’s questions?