#################################################
# hw11.py
#
# Your name:
# Your andrew id:
#################################################

import cs112_n21_week4_linter
import math, copy

#################################################
# Helper functions
#################################################

def almostEqual(d1, d2, epsilon=10**-7):
    # note: use math.isclose() outside 15-112 with Python version 3.5 or later
    return (abs(d2 - d1) < epsilon)

import decimal
def roundHalfUp(d):
    # Round to nearest with ties going away from zero.
    rounding = decimal.ROUND_HALF_UP
    # See other rounding options here:
    # https://docs.python.org/3/library/decimal.html#rounding-modes
    return int(decimal.Decimal(d).to_integral_value(rounding=rounding))

# from: https://www.cs.cmu.edu/~112/notes/notes-strings.html#basicFileIO
def readFile(path):
    with open(path, "rt") as f:
        return f.read()

#################################################
# Functions for you to write
#################################################

def formatDataset(filename):
    return 42

def friendsOfUser(userId, friendData):
    return 42

def mutualFriends(userId1, userId2, friendData):
    return 42

def facebookDataAnalysis():
    return '''
** All of the questions below are pertaining to the largeFacebook.txt file **

Q1: Who has the most friends in the data? (give their userId as your answer)
A1: 42

Q2: How many friends does the person from Q1 have?
A2: 42

Q3: Who has the second-most friends in the data? (give their userId)
A3: 42

Q4: How many friends does the person from Q3 have?
A4: 42

Q5: Which two users have the most mutual friends in the full data?
    Put the smallest userID first!
A5: 42 and 42
'''

#################################################
# Test Functions
#################################################

def testFriendsOfUser():
    print("Testing friendsOfUser()...", end="")
    friendData = formatDataset('smallFacebook.txt')
    assert(friendsOfUser(881, friendData) == {871, 879, 870, 858, 
                                866, 895})
    assert(friendsOfUser(745, friendData) == {697, 810, 747, 830, 
                                823, 774, 713, 719, 828, 800, 805})
    print("Passed!")

def testMutualFriends():
    print("Testing mutualFriends...", end="")
    friendData = formatDataset('mediumFacebook.txt')
    assert(mutualFriends(236, 122, friendData) == {141, 142, 271, 272, 276, 21, 
                                280, 25, 26, 169, 297, 303, 304, 186, 315, 62, 
                                322, 67, 200, 213, 224, 248, 252})
    assert(mutualFriends(21, 7, friendData) == {322, 136, 304, 308, 315, 31})
    print("Passed!")

def testFacebookDataAnalysis():
    print("Skipping testing for facebookDataAnalysis() :)")

#################################################
# testAll and main
#################################################

def testAll():
    testFriendsOfUser()
    testMutualFriends()
    testFacebookDataAnalysis()

def main():
    cs112_n21_week4_linter.lint()
    testAll()

if __name__ == '__main__':
    main()