inswers = %3D - ["tank", "godzilla", "tank"] ["tank"] nputs.append(L) answers.append(a) FESTS assed len(inputs)
inswers = %3D - ["tank", "godzilla", "tank"] ["tank"] nputs.append(L) answers.append(a) FESTS assed len(inputs)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
![from surround import surround
inputs = []
[]
answers =
L = ["tank", "godzilla", "tank"]
["tank"]
inputs.append (L)
answers.append(a)
a =
TESTS len(inputs)
passed = 0
for i in range(TESTS):
try:
result = surround (inputs[i])
if result not in answers[i]:
print("Error found for input: " + str(inputs[i]))
else:
passed += 1
except Exception:
pass
result = "Tests passed:
+ str(passed) + "/" + str(TESTS)
print(result)](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0319c00d-f6bb-4aa5-a904-f8fc949000f8%2Fa625563a-ba35-42de-8adf-9ea4349869f0%2Ff15kfhq_processed.jpeg&w=3840&q=75)
Transcribed Image Text:from surround import surround
inputs = []
[]
answers =
L = ["tank", "godzilla", "tank"]
["tank"]
inputs.append (L)
answers.append(a)
a =
TESTS len(inputs)
passed = 0
for i in range(TESTS):
try:
result = surround (inputs[i])
if result not in answers[i]:
print("Error found for input: " + str(inputs[i]))
else:
passed += 1
except Exception:
pass
result = "Tests passed:
+ str(passed) + "/" + str(TESTS)
print(result)
![When Godzilla attacks a city, army units try to surround him to stop his rampage.
to surround Godzilla the most often.
It's useful to know which unit is able
Write a function called surround () that accepts one parameter: a list of strings. Each string in the list will either be
the special value "godzilla", or the name of a unit.
You may assume all strings are lower case.
The value "godzilla" may occur in the list any number of times. Each time it appears, Godzilla is considered surrounded if
both of the unit names IMMEDIATELY on either side of him in the list are the same.
Note that Godzilla is not a unit, and
therefore cannot surround himself!
The function should return the NAME of the unit that most frequently surrounds Godzilla. If there is a TIE, then it should
return a single name from among those tied (it does not matter which). If no units ever surround Godzilla, it should
return the empty string.
For example:
["tank", "godzilla", "tank"] should return "tank"
["tank", "godzilla", "missile"] should return ""
["godzilla", "tank"] should return ""](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0319c00d-f6bb-4aa5-a904-f8fc949000f8%2Fa625563a-ba35-42de-8adf-9ea4349869f0%2Fqvb90ip_processed.jpeg&w=3840&q=75)
Transcribed Image Text:When Godzilla attacks a city, army units try to surround him to stop his rampage.
to surround Godzilla the most often.
It's useful to know which unit is able
Write a function called surround () that accepts one parameter: a list of strings. Each string in the list will either be
the special value "godzilla", or the name of a unit.
You may assume all strings are lower case.
The value "godzilla" may occur in the list any number of times. Each time it appears, Godzilla is considered surrounded if
both of the unit names IMMEDIATELY on either side of him in the list are the same.
Note that Godzilla is not a unit, and
therefore cannot surround himself!
The function should return the NAME of the unit that most frequently surrounds Godzilla. If there is a TIE, then it should
return a single name from among those tied (it does not matter which). If no units ever surround Godzilla, it should
return the empty string.
For example:
["tank", "godzilla", "tank"] should return "tank"
["tank", "godzilla", "missile"] should return ""
["godzilla", "tank"] should return ""
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 2 images

Similar questions
Recommended textbooks for you

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

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