When two soldiers are dropped at positions (5,5) and (5,3) then the total number of buildings controlled by soldiers are 22. No. of buildings in column 3 + No. of buildings in column 5 + No. of buildings in row 5-No. of buildings common among them = 8 + 8 + 8 -2 = 22 Therefore, 22 is returned as the output.

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
Please code the below question in any one of these languages C or C++ or Java6 or python2 or Java 7 or Python 3 or PHP or Go or R ( Any one of these)
Output: 22
Explanation:
When two soldiers are dropped at positions (5,5) and (5,3) then the total
number of buildings controlled by soldiers are 22.
No. of buildings in column 3 + No. of buildings in column 5 + No. of buildings in
row 5-No. of buildings common among them = 8+8+8 -2=22
Therefore, 22 is returned as the output.
Example 2:
input1: 1
input2: {{4,4}}
Output: 15
Explanation:
When one soldier is dropped at position (4,4) then the total number of buildings
controlled by the soldier is 15.
No. of buildings in column 4 + No. of buildings in row 4 - No. of buildings common
among them = 8+8-1=15
Therefore, 15 is returned as the output.
Transcribed Image Text:Output: 22 Explanation: When two soldiers are dropped at positions (5,5) and (5,3) then the total number of buildings controlled by soldiers are 22. No. of buildings in column 3 + No. of buildings in column 5 + No. of buildings in row 5-No. of buildings common among them = 8+8+8 -2=22 Therefore, 22 is returned as the output. Example 2: input1: 1 input2: {{4,4}} Output: 15 Explanation: When one soldier is dropped at position (4,4) then the total number of buildings controlled by the soldier is 15. No. of buildings in column 4 + No. of buildings in row 4 - No. of buildings common among them = 8+8-1=15 Therefore, 15 is returned as the output.
A neighborhood of Park Street is raided by soldiers in search of Agent Y. They
land on different buildings on a helicopter. The rooftops of these buildings are
connected to each other through ladders. Each soldier can take control of the
buildings in a straight line (left-right and forward-backward), with respect to the
building/position they have been dropped at. They cannot take control of
buildings diagonally.
There are 8 buildings in each row and column. Your goal is to determine and
return the total number of buildings that are controlled by these group of
soldiers.
Note: A soldier also controls the building on which he/she is currently positioned/dropped.
Input Specification:
input1: An integer value representing the number of soldiers that have
landed
input2: A 2-D array of size input1*2 representing 'x' and 'y' coordinate
positions of the soldiers starting from {1,1}
Output Specification:
Return the total number of buildings that are controlled by the soldiers
Example 1:
input1: 2
input2: {{ 5.5).(5.3}}
Transcribed Image Text:A neighborhood of Park Street is raided by soldiers in search of Agent Y. They land on different buildings on a helicopter. The rooftops of these buildings are connected to each other through ladders. Each soldier can take control of the buildings in a straight line (left-right and forward-backward), with respect to the building/position they have been dropped at. They cannot take control of buildings diagonally. There are 8 buildings in each row and column. Your goal is to determine and return the total number of buildings that are controlled by these group of soldiers. Note: A soldier also controls the building on which he/she is currently positioned/dropped. Input Specification: input1: An integer value representing the number of soldiers that have landed input2: A 2-D array of size input1*2 representing 'x' and 'y' coordinate positions of the soldiers starting from {1,1} Output Specification: Return the total number of buildings that are controlled by the soldiers Example 1: input1: 2 input2: {{ 5.5).(5.3}}
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
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