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...
icon
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)
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 ""
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
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
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 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)
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
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY