Sociopath

A. Introduction

  • A friendship monitoring system

  • If one is reliable when working on assignments together

2. Problem Statement

Generate a group of 10 students, each with

  • rep - reputation [1,10]

  • dive - diving rate [0,100]

  • lunchStart - lunch starting time

  • lunchPeriod - lunch period (5,60)

  • friends - friends (list with rep)

2.1 Initialization

Initialize these variables for each student as below:

1 <= rep <= 10,

0 < Diving rate (%) < 100,

1100 <= lunch time <= 1400,

5 < lunch period(minutes) < 60,

a list of friends as shown in Figure 1 below with their reputation relative to this person.

2.2 Events

Create multiple events to manipulate the data in your system.

2.2.1 Teaching a stranger to solve lab questions

A stranger is seeking your help to solve the question, you will always help them.

  • If you did something good to a person

    • increase your rep points relative to that person by 10.

    • stranger becomes your friend

    • He or she might tell his/her friends about you.

  • But if you are bad at programming,

    • you will still be friends with him,

    • your rep points relative to that person will be 2 instead (Note that you were strangers before this, now you guys are friends and your rep point relative to that person is 2).

  • But how do the messages about you spread or go viral?

2.2.2 Chit-Chat

your new friend will have a chit-chatting session with his or her friends.

  • If it’s a good message,

    • increases your rep points relative to them by your rep points relative to your new friend * 0.5.

  • Otherwise, if it’s a bad message,

    • this person will share the same negative rep points, that your new friend owns about you.

    • Later, your new friend’s friends might tell their friends, so it will multiply and propagate your rep.

For example, A has a rep points of 10 relative to B, B and C chit-chatting and speak about A’s good side. So, A rep point will be +5 (50% of A rep points to B) relative to C. Meanwhile, if B and C are talking about A’s bad side, A rep point will be -10 (100% of A rep point to B) relative to C.

2.2.3 Your road to glory

If you want to build a good relationship with someone, try to have lunch with them.

But you want to be efficient. You want to maximize the amount of reputation you can gain by befriending people with high reliability.

To do this, you will keep track of 2 observations for each person you are interested in,

  • the time that they will have lunch,

  • the duration of their meal to find out the average time of their lunch hour

  • the average time it takes them to finish their lunch.

You will then use these statistics to calculate an interval for each person (i.e., the start and end times). Use these to

  • find the maximum reputation you can obtain in any day given that you can only have lunch with one person at one time.

  • Each person that had lunch with you will increase your rep with them by 1 point.

2.2.4 Arranging books

you joined a volunteering program to arrange books.

The librarian has two special requests:

  1. make sure the height of a row of books is in non-increasing order

    Example of non-increasing order:

    • 4, 4, 3, 3, 2

    • 4, 3, 2, 1, 0

  2. solve this using the stack data structure.

  • There is only one row of books on the bookshelf. In this row of books, every book has different heights.

  • For each round, you’ll move from left to right to pick out the book that did not meet the request. At the end of each round, you'll be on the right side of the bookshelf. You put the book(s) down because it’s heavy to carry.

  • Then the next round starts, you start over again moving from left to right.

While you’re moving from left to right, you will just check if a book is higher than the book on the left and take it out.

Note that if book A = 15cm, book B = 16cm, book C = 17cm and they’re arranged in the order ABC, both book B and C will be taken out, and only book A left for the next round of picking.

For example, height = [3, 1, 10, 7, 3, 5, 6, 6] After first round = [3, 1, 7, 3, 6] After second round = [3, 1, 3] Hence, you will need 2 rounds to meet the librarian’s request.

You are given the heights of the books. Determine the number of rounds needed to make the height of the books in non-increasing order. Make your program accept the input and print the number of rounds needed for you to make the row of books in non-increasing order.

io example

Input:
7
6 5 8 4 7 10 9
Output:
2
Input:
5
13 16 12 17 15
Output:
2

2.2.5 Meet your crush

While you join the volunteering program, there’s this guy/gal. You haven’t spoken to him/her, you got a crush on him/her.

Sadly, there will be rumors out of nowhere from one of the strangers. By the nature of chit-chatting, you know it will be a disaster if your crush knows about the false allegation.

So, who do you have to convince to clarify the rumor about you to prevent it from getting to your crush? The rumor will start in the stranger’s cluster and your crush is in another cluster. You might identify someone connected between these 2 clusters. Then, you can convince him/her on the rumor so that your crush won’t hear the rumor. If there is more than one person that needs to be convinced to prevent the rumor from spreading, then you can’t do it because you can only convince one person per day.

Calculate that the rumor propagates at one jump per day and identify if you can convince enough people to prevent your crush from knowing about the rumor

2.2.6 Friendship

University is a place to meet new people! There are many ways for us to meet new friends, we will make new friends out of our friends’ friends through some opportunities.

For example, A and B are friends and B and C are friends, A will eventually meet C! (Note that friendship is undirected which means A - B is equal to B - A, A-B-C is equal to C-B-A).

You are given a list of an integer n, followed by n lines of existing friendships between 2 individuals. You need to find the total number of unique ways the friendship can be formed. It is guaranteed that the relationship between all individuals are connected (all individuals will eventually meet each other).

3. Additional Challenge

3.1 GUI

  • GUI / HTML, CSS, JS

  • displaying the data of the system, creating a dashboard of the system, and controlling it

3.2 Social dynamics

Social networks are complicated and having simple edges representing 2 friends isn’t enough modeling power for you to conquer the world.

Implement different kinds of edges like enemies and frenemies with their own unique dynamics and interactions. Explain the motivations for your implementation and give us a glimpse of your sociopathic mind!

3.3 Matchmaker

(fake) Research shows that 89.3% of friend groups split because of romantic rivalry. This would be terrible for you and you are going to do everything within your power to prevent a rivalry from dividing your friend group. In order to do this, you are going to have to play matchmaker.

Implement an algorithm that calculates a stable matching for your friend group so that you can prevent rivalries from developing by matching your friends with a stable partner. Context on stable matching and the mating algorithm: https://www.youtube.com/watch?v=5RSMLgy06Ew

3.4 Parallel farming

You’ve gained a bit of influence and now have the power to invite people to eat lunch at your table. So why eat with 1 person when the table is big enough for 3? Upgrade your system in Event 3 to be able to calculate the maximum reputation you can obtain given that you can eat with 3 people at any one time.

3.5 Life’s not a game that you play to get even

Implement functionality to ingest data from social media. Using the sociopath app has greatly improved your ranking on the social ladder. But it’s so tedious! So many relationships to keep track of, bits and pieces of information that all need to be manually keyed. What a hassle. Fortunately, people nowadays post all their social information on mysterious sites called social media. Wouldn’t it be great if you could dynamically scrape the data (whether A is a friend of B and if they comment on each other’s posts) from these social media sites to get the latest insights into the social atmosphere?

3.6 Herd Immunity

Vaccines are scarce at the beginning of a post-COVID world and it would be great if they go to people who would make the most impact in stopping it from spreading among clusters of friends.

Analysis of the theory of six degrees of separation has found that it is usually achieved by a few people who link multiple friend circles. These people are perfect bridges for the spread of the virus and would be ideal vaccination targets for stopping the spread of the virus.

Create an algorithm that takes the number of vaccines as input and identifies who should be vaccinated such that the maximum size of any friend cluster is minimal.

3.7 Six degrees to Ken Thompson

Speaking of six degrees of separation, one of the demos is a huge fan of Ken Thompson.

Use the sociopath app to calculate a path of correspondence between you and Ken Thompson that is less than or equal to 6 hops. Present your methodology on identifying and validating this path.

D. Tips and comments

1. Use git to do version control

2. Learn graph algorithms

3. Use graph databases

E. Questions

If you have any questions regarding the question, you can email helpdeskdatastructure@gmail.com with the title (Sociopath).

Last updated