Skip to content

Instantly share code, notes, and snippets.

@achikin
Last active October 5, 2022 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save achikin/ada1a95ad12b38077f47130c2bddd6fe to your computer and use it in GitHub Desktop.
Save achikin/ada1a95ad12b38077f47130c2bddd6fe to your computer and use it in GitHub Desktop.
Test assignment

Given social network posts in the following format:

[
 {"date": "12.10.2019",
  "text": "I love trouts!",
  "likes": [1, 2, 3, 4]},
  
  {"date": "17.10.2019",
  "text": "Hello world!",
  "likes": [1, 2, 3, 4]}б
  ...
]

likes is a list of user ids that liked a post

And given users in the following format

[
  {"id": 1
   "name": "John"},
   ...
]

Find the names of the users, that liked all posts. Example:

// posts
[
  {"date": "21.12.2019",
   "text": "Fish!",
   "likes": [1, 2]},
   
   {"date": "21.12.2019",
    "text": "Apples :((",
    "likes": [1, 2, 3]}
]
//users
[
  {"id": 1,
   "name": "John"},
  {"id": 2,
   "name": "Mary"},
   {"id": 3,
   "name": "Jane"},
]

The result should be:
["Mary", "John"]

Any questions are welcome!

Useful hints

[
{"id": 1,
"date": "12.10.2019",
"text": "I like fish.",
"likes": [2, 3, 6]},
{"id": 2,
"date": "15.10.2019",
"text": "I hate apples",
"likes": [6, 1, 2, 3, 4]},
{"id": 3,
"date": "23.12.2019",
"text": "I bought an iPhone.",
"likes": [6, 2]},
{"id": 4,
"date": "02.02.2020",
"text": "Vote for spaghetti!",
"likes": [5, 1, 3, 6, 2]},
{"id": 5,
"date": "31.05.2020",
"text": "How do you like the last Marvell movie?",
"likes": [2, 6, 1]},
{"id": 6,
"date": "01.01.2022",
"text": "I hate fish.",
"likes": [3, 4, 6, 2]},
{"id": 7,
"date": "31.12.2022",
"text": "I saw the Bigfoot on my backyard.",
"likes": [4, 1, 2, 6]},
{"id": 8,
"date": "01.03.2019",
"text": "I'm having fun in Paris",
"likes": [1, 2, 3, 4, 5, 6]},
{"id": 9,
"date": "12.10.2019",
"text": "Check out my new clojure library github.com/user/clojure-library",
"likes": [6, 1, 2, 3, 4]}
]
[
{"id": 1, "name": "John"},
{"id": 2, "name": "Mary"},
{"id": 3, "name": "Anton"},
{"id": 4, "name": "Batman"},
{"id": 5, "name": "Jesica"},
{"id": 6, "name": "Ivan"},
{"id": 7, "name": "Petra"}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment