Given: Input, Constraints, Output You find yourself in a top secret mission to infiltrate and disable the nuclear missile silos of a terrorist organization threatening to destroy any country that refuses to surrender. Fortunately, an ally double agent was able to successfully hijack the launch system used by the terrorists. However, in order to not get found out, they could not disable the system outright but they were able to infect the system with an undetectable Input Format The first line of the input is an integer, n, where n is the number of rows and columns of the grid. virus that stops all processes of the system was activited. Then there will be n succeeding lines with each withn digits separated by spaces. Through a secure line, the double agent gives you the instructions in order to activate the virus and stop all Constraints missiles from firing: 0

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

Python

Hackerrank Activity

Make a program in Python using the following: (see pic)

will give high rating if pass all testcases (see Sample Output 0 and Sample Output 1)

 

 

Given:
Input, Constraints, Output
You find yourself in a top secret mission to infiltrate and disable the nuclear missile silos of a terrorist
organization threatening to destroy any country that refuses to surrender. Fortunately, an ally double agent
was able to successfully hijack the launch system used by the terrorists. However, in order to not get found
out, they could not disable the system outright but they were able to infect the system with an undetectable
Input Format
The first line of the input is an integer, n, where n is the number of rows and columns of the grid.
virus that stops all processes of the system was activited.
Then there will be n succeeding lines with each with n digits separated by spaces.
Through a secure line, the double agent gives you the instructions in order to activate the virus and stop all
missiles from firing:
Constraints
0 <n < 2000
1. In the trash can nearest the main computer, you should be able to get a crumpled piece of paper with a
grid of random numbers printed onto it. You will know that it is the right piece of paper if there are the
same number of rows and columns in the grid.
0 < d< 1000 for each digit d in the grid.
It is guaranteed that each test case would only have sequence that satisifies the conditions needed.
2. Find the sequence of consecutive rows where the difference of the sum of the elements of the odd-
numbered rows from the sum of the elements in the even numbered rows are maximum .
Your soltuion should have a log-linear (O(n log n)) worst-case time complexity.
3. Get the first number in the first row of the sequence, then the second element of the second row in the
sequence and so on until the corresponding element in the last row in the sequence.
(11 March 2022) Additional notes and clarifications: you are allowed to have at most one loop with O(n2)
time. The rest of your program/functions should all be below or equal to O(m log n). Failure to meet these
4. Enter these numbers on the main computer and run away as fast as you can.
constraints would result in a 50% decution for your grade in this activity.
Output Format
Being fast is very important as it will minimize your chances of getting caught. Luckily, you can bring with you
on the mission a small computer which can run a program to look for the palindromic number for you. Good
One line for each number in the activation code.
luck on your mission!
Transcribed Image Text:Given: Input, Constraints, Output You find yourself in a top secret mission to infiltrate and disable the nuclear missile silos of a terrorist organization threatening to destroy any country that refuses to surrender. Fortunately, an ally double agent was able to successfully hijack the launch system used by the terrorists. However, in order to not get found out, they could not disable the system outright but they were able to infect the system with an undetectable Input Format The first line of the input is an integer, n, where n is the number of rows and columns of the grid. virus that stops all processes of the system was activited. Then there will be n succeeding lines with each with n digits separated by spaces. Through a secure line, the double agent gives you the instructions in order to activate the virus and stop all missiles from firing: Constraints 0 <n < 2000 1. In the trash can nearest the main computer, you should be able to get a crumpled piece of paper with a grid of random numbers printed onto it. You will know that it is the right piece of paper if there are the same number of rows and columns in the grid. 0 < d< 1000 for each digit d in the grid. It is guaranteed that each test case would only have sequence that satisifies the conditions needed. 2. Find the sequence of consecutive rows where the difference of the sum of the elements of the odd- numbered rows from the sum of the elements in the even numbered rows are maximum . Your soltuion should have a log-linear (O(n log n)) worst-case time complexity. 3. Get the first number in the first row of the sequence, then the second element of the second row in the sequence and so on until the corresponding element in the last row in the sequence. (11 March 2022) Additional notes and clarifications: you are allowed to have at most one loop with O(n2) time. The rest of your program/functions should all be below or equal to O(m log n). Failure to meet these 4. Enter these numbers on the main computer and run away as fast as you can. constraints would result in a 50% decution for your grade in this activity. Output Format Being fast is very important as it will minimize your chances of getting caught. Luckily, you can bring with you on the mission a small computer which can run a program to look for the palindromic number for you. Good One line for each number in the activation code. luck on your mission!
Sample Input 0
Sample Input 1
10
23
16
25
12
19
45
88
18
87
32
12
89
27
19
11
1
4
36
68
24
96
57
82
80
73
45
11
3
6
7
20
73
95
39
21
8
83
93
65
56
18
24
4
17
5
85
34
64
96
23
3
19
7
12
59
3
4
40
15
46
44
50
58
66
33
42
20
67
95
75
19
34
34
98
65
30
9
49
10
55
54
62
98
7
25
Sample Output 0
97
20
9
74
75
100
79
100
70
71
2
35
47
58
79
94
41
6
31
94
95
34
21
58
17
2
78
12
27
10
11
9
Sample Output 1
Explanation 0
20
9
10
23
16
25
12
Explanation 1
90
19
45
88
18
87
32
12
89
27
19
11
8
1
4
36
68
24
96
57
82
80
73
45
11
56
73
95
39
21
8
83
93
65
56
3| 6| 9
7
20
85
34
64
96
23
3
19
7
12
59
67
40
15
46
44
50
58
66
33
42
20
67
3
95
75
19
34
34
98
65
18
24
17
30
49
10
55
54
62
98
7
25
97
20
74
75
100
79
100
70
7
3
4
6
1
71
2
35
47
58
79
94
41
31
94
95
34
21
58
17
2
78
12
27
Transcribed Image Text:Sample Input 0 Sample Input 1 10 23 16 25 12 19 45 88 18 87 32 12 89 27 19 11 1 4 36 68 24 96 57 82 80 73 45 11 3 6 7 20 73 95 39 21 8 83 93 65 56 18 24 4 17 5 85 34 64 96 23 3 19 7 12 59 3 4 40 15 46 44 50 58 66 33 42 20 67 95 75 19 34 34 98 65 30 9 49 10 55 54 62 98 7 25 Sample Output 0 97 20 9 74 75 100 79 100 70 71 2 35 47 58 79 94 41 6 31 94 95 34 21 58 17 2 78 12 27 10 11 9 Sample Output 1 Explanation 0 20 9 10 23 16 25 12 Explanation 1 90 19 45 88 18 87 32 12 89 27 19 11 8 1 4 36 68 24 96 57 82 80 73 45 11 56 73 95 39 21 8 83 93 65 56 3| 6| 9 7 20 85 34 64 96 23 3 19 7 12 59 67 40 15 46 44 50 58 66 33 42 20 67 3 95 75 19 34 34 98 65 18 24 17 30 49 10 55 54 62 98 7 25 97 20 74 75 100 79 100 70 7 3 4 6 1 71 2 35 47 58 79 94 41 31 94 95 34 21 58 17 2 78 12 27
Expert Solution
steps

Step by step

Solved in 4 steps with 3 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