Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Q3: Superheroes
Supervillains are tired of Toronto condo rental prices, so they are leaving Toronto for Mississauga.
Luckily, we have valiant superheroes that can deal with them. The superhero () has a name , an intelligence score , and a strength score .ni-th0 = gin[x] + s[x]
Detective Zingaro has asked for your help. For each of the supervillains, tell him the name of the superhero that should deal with that supervillain.
Note: A superhero can be assigned to multiple supervillains (or none at all).
Note: whenever there are multiple superheroes that satisfy the given requirements for a supervillain, report the one whose name is lexicographically smallest (i.e. the one that’s the smallest according to Python’s ordering of strings). It’s guaranteed that superheroes have distinct names.
Hint: Tuples of multiple elements may be helpful here. In python, you can compare two tuples and . If and are different, the result is the same as comparing and . If and are equal, the result is the same as comparing and . You can even sort these tuples!(a, b)(c, d)acacacbd
Filename
Your filename for this question must be .q3.py
Input
The first line of the input contains a single integer denoting the number of superheroes.n
The next three lines describe the superheroes. The first line contains space-separated strings, specifying the names of the superheroes. The second line contains space-separated integers, specifying the list . Finally, the third line specifies the list .nnins
The next line contains a single integer denoting the number of supervillains. lines will follow describing them, one per line. Each of these lines starts with an integer denoting the type of the villain (, , or ), followed by an integer specifying the corresponding threshold.mmt123
Output
Your output should consist of strings separated by spaces. The one should be the name of the superhero assigned to the supervillain. If no superhero meets the requirements for a supervillain, output for that supervillain instead.mi-thi-thnone
Constraints
1
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.Similar questions
- Interest on a credit card’s unpaid balance is calculated using the average daily balance. Suppose that netBalanceis the balance shown in the bill, paymentis the payment made, d1is the number of days in the billing cycle, and d2is the number of days payment is made before the billing cycle. Then the average daily balance is: averageDailyBalance = (netBalance * d1 –payment * d2) / d1 if the interest rate per month is say, 0.0152, then the interest on the unpaid balanceis: interest = averageDailyBalance * 0.0152 Design a program that accepts as input netBalance, payment, d1, d2, and interest rate per month. The program outputs the interest charged. Format your output to two decimal places. C++arrow_forwardPlease Answer in C++ only A Rajesh teaches a cooking class. The course is attended by NN students, numbered 11 to NN. The cook must participate in the presence before each class, i.e. call out the names of the students one by one and indicate which students are present. Each student has a first and last name. To save time, Rajesh only wants to call up students' first names. However, if there are multiple students with the same first name, the Rajesh must call out the full names (first and last names) of all those students. For any student who does not share a first name with any other student, the cook can still only call that student's first name. Help the Rajesh decide for each student whether to call that student's full name or just their first name. Input 1 1 hasan jaddouh Output hasanarrow_forwardSummary Interest on a credit card's unpaid balance is calculated using the average daily balance. Suppose that netBalance is the balance shown in the bill, payment is the payment made, d1 is the number of days in the billing cycle, and d2 is the number of days payment is made before billing cycle. Then, the average daily balance is: averageDailyBalance = (netBalance * d1 payme If the interest rate per month is, say, 0.0152, then the interest on the unpaid balance is: interest averageDailyBalance * 0.0152 Instructions Write a program that accepts as input netBalance, d1, payment, d2, and interest rate per month ( interestRate).arrow_forward
- Code in C++ please, with comments to guide the code.arrow_forwardGiven: (3,6) int numi, num2, newNum; double x, y; Which of the following assignments are valid? If an assignment is not valid, state the reason. a. numl = 35; b.newNum = numl - num2; c.numl = 5;num2 = 2 + numl;numl = num2 I 3; d. numl * num2 = newNum; e.x = 12 * numl - 15.3; f.numl * 2 = newNum + num2; g. x / y = x * y; h. num2 = numl % 2.0; i.newNum = static_cast<int> (x) % 5; j.x = x + y - 5; k. newNum = numl + static_cast<int> (4.6/2);arrow_forwardQ1: Research Groups In response to popular demand, Dan’s established two research groups A and B composed of his n graduate students. Each of these students is a member of exactly one of the two groups at any given time. The students are numbered from 1 to n in some arbitrary order. To measure the success of his research groups, Dan assigns a citation score to each of them. Initially, both groups have citation score 0. Throughout the semester, events of the following two types happen: Student x publishes a paper in which they cite student y’s work (youcan assume all of the students have been around long enough to have prior research that can be cited). As a result, If x and y are in the same group, their group’s citation score increases by 1. If x and y are in different groups, y’s group’s citation score increases by 5. Dan changes student x’s group (from A to B or from B to A) to have them work on different projects. To assess the overall success of the research groups, Dan…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY