Please Write it in Python. AND please in the function circleoffriends() i want the logic to account for the numbers fro

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Please Write it in Python. AND please in the function circleoffriends() i want the logic to account for the numbers fro

Post by answerhappygod »

Please Write it in Python. AND please in the functioncircleoffriends() i want the logic to account for the numbersfrom 1-n that are not explicitly mentioned in any of thetuples that are not given in the list of tuples and groupthem together and print as a new group of friends. This is alreadymentioned in the question but i wanted to clarify that the examplegiven in the picture is correct. another example would becirlceofriends(9,[(1,2),(2,3),(3,5),(5,7)] the output wouldthen be friend circle 1 : [1,2,3,5,7] friend circle 2 is[4,6,8,9]
Please Write It In Python And Please In The Function Circleoffriends I Want The Logic To Account For The Numbers Fro 1
Please Write It In Python And Please In The Function Circleoffriends I Want The Logic To Account For The Numbers Fro 1 (55.02 KiB) Viewed 20 times
Let's assume that two people sharing a friend must be friends themselves. For example, if person 1 and person 2 are friends, and person 2 and person 3 are friends, then person 1 and person 3 must be friends. Write a function CirclesOfFriends(n, 1st) that partitions people in a company into circles of friends. The function takes 2 inputs; n as the total number of people and Is is a list of tuples representing pairs of friends. People who are not part of any circle of friends are automatically placed together in a new circle of friends. The output should be the partition of circles of friends. For example: >>> CirclesOfFriends (7, [(1, 2), (2, 3), (4, 6)]) Friend Circle 1 is [1, 2, 3] Friend Circle 2 is [4, 6] Friend Circle 3 is [5,7]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply