Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Max Contiguous Subarray

Given a list of integers, write a program to identify the contiguous sub-list that has the largest sum and print the sum. Any non-empty slice of the list with step size 1 can be considered as a contiguous sub-list.Input


The input will contain space-separated integers, denoting the elements of the list.Output


The output should be an integer.Explanation


For example, if the given list is [2, -4, 5, -1, 2, -3], then all the possible contiguous sub-lists will be,

[2]
[2, -4]
[2, -4, 5]
[2, -4, 5, -1]
[2, -4, 5, -1, 2]
[2, -4, 5, -1, 2, -3]
[-4]
[-4, 5]
[-4, 5, -1]
[-4, 5, -1, 2]
[-4, 5, -1, 2, -3]
[5]
[5, -1]
[5, -1, 2]
[5, -1, 2, -3]
[-1]
[-1, 2]
[-1, 2, -3]
[2]
[2, -3]
[-3]

Among the above contiguous sub-lists, the contiguous sub-list [5, -1, 2] has the largest sum which is 6.

Sample Input 1

2 -4 5 -1 2 -3

Sample Output 1

6

Sample Input 2

-2 -3 4 -1 -2 1 5 -3

Sample Output 2

7




 code in  Question #175894  gives result:12x^4 + 9x^3 + -5x^2 - 1x - 1 but 12x^4 + 9x^3 - 5x^2 - x - 1 is desired output.
how to get desired result .
input = 
5
0 -2
3 6
4 7
1 -3
2 -1
5
0 1
1 2
2 -4
3 3
4 5


 Question #175894 




M, N = input().split()

M, N = int(M), int(N)

matrix = []

for _ in range(M):

row = [int(x) for x in input().split(' ')]

matrix.append(row)

K = int(input())

values = matrix[0][:-1] + [x[-1] for x in matrix][:-1] + matrix[-1][::-1][:-1] + [x[0] for x in matrix][::-1][:-1]

values = values[-K:] + values[:-K]

output = matrix

idxs = [(0, j) for j in range(N)][:-1] + [(i, N - 1) for i in range(M)][:-1] + [(M - 1, j) for j in range(N)][::-1][:-1] + [(i, 0) for i in range(M)][::-1][:-1]

idx = 0

for i, j in idxs:

output[i][j] = values[idx]

idx += 1

print(output)

input:4 4

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15 16

3

output should be like this:

13 9 5 1

14 7 11 2

15 6 10 3

16 12 8 4 can you please make code


integers = [int(number) for number in input().split()]

K = int(input())

triplets = []

for i in range(len(integers)):

  for j in range(i+1,len(integers)):

    for k in range(j+1, len(integers)):

      a = integers[i]

      b = integers[j]

      c = integers[k]

      if a+b+c == K:

        triplets.append(tuple((a,b,c)))

sorted_triplets=[]

for tripl in triplets:

  item = sorted(tripl)

  sorted_triplets.append(item)

triplets= sorted(sorted_triplets)

if len(triplets)!=0:

  for triplet in triplets:

    triplet=sorted(triplet)

    tuple_a=tuple(triplet)

    print(tuple_a)

input:0 1 2 3 5 7 13 17 19 19

22

output should be like this :

(0, 3, 19)

(0, 5, 17)

(1, 2, 19)

(2, 3, 17)

(2, 7, 13)


You are given three numbers. Check if any of the numbers exist in the range from 10 to 20 (including 10 and 20).




Many drugs, legal or not, work by either stimulating or inhibiting specific metabolic enzymes. As such, products of metabolic reactions can be selectively increased or decreased depending on the drug’s mechanism of action in the cell. In your readings, you learned that statins are a class of drugs used to reduce cholesterol levels. Their mechanism of action is to inhibit the enzyme HMG-CoA reductase. HMG-CoA reductase is the enzyme that synthesizes cholesterol from lipids in the body. By inhibiting this enzyme, the levels of cholesterol synthesized in the body can be reduced.

You will research and present a drug of your choosing for this assignment. You are free to chose any drug as long as it works by inhibiting a specific enzyme; e.g., statins. You cannot, however, use statins.


Write a 2-3 page (500 – 750 words, 12 point font) paper including the following elements. Be sure to compose your work with your own words. Do not copy and paste from any source.


integers = [int(number) for number in input().split()]

K = int(input())

triplets = []

for i in range(len(integers)):

  for j in range(i+1,len(integers)):

    for k in range(j+1, len(integers)):

      a = integers[i]

      b = integers[j]

      c = integers[k]

      if a+b+c == K:

        triplets.append(tuple((a,b,c))) input:0 12 17 8 9 21

sorted_triplets=[] 29

for tripl in triplets:

  item = sorted(tripl) output:[0, 8, 21]

  sorted_triplets.append(item) [0, 12, 17]

triplets= sorted(sorted_triplets) [8, 9, 12]

if len(triplets)!=0:

  for triplet in triplets: output should be like this:(0, 8, 21)

    triplet=sorted(triplet) (0, 12, 17)

    print(triplet) (8, 9, 12)

else: output should be in round braces

  print("No Matching Triplets Found")



Given a matrix of order M*N and a value K, write a program to rotate each ring of the matrix clockwise by K elements. If in any ring has less than or equal to K elements, then don’t rotate that ring.

For example, if the given M and N are 4 and 4 respectively. If the matrix elements are

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15 16

If the given K is 3. Rotate each ring of the matrix by 3 elements.

In the above matrix, the elements (1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5) is a ring, similarly, the elements (6, 7, 11, 10) will make a ring.

Therefore, by rotating each ring in clockwise direction by 3 elements will give (13, 9, 5, 1, 2, 3, 4, 8, 12, 16, 15, 14) and (10, 6, 7, 11). So the output should be

13 9 5 1

14 7 11 2

15 6 10 3

16 12 8 4

input:4 4

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15 16

3

output should print like this:13 9 5 1

14 7 11 2

15 6 10 3

16 12 8 4


H/w question 6

Create a program in Python, called Tri-Calculator, that uses a function to calculate the area of a triangle given the base and height measurements. Use the below function to do your calculation:


def area_of_triangle (base, height); return 0.5 * base * height


The program should receive the base and the height from the user. Once the user enter a base greater than the height the program should give the user another attempt to enter a base and a height. The program only give the user three attempts to enter the correct base and height on the third attempt the program should display the below message:

"Your 3 attempts is up, try again later"

If the user enters a base less than height, the program should display the correct triangle area using the given function.

(it should contain a function, loop, if statement and sentinel value)


Develop User Interface as mentioned below as per the requirements:

Button One: Activate Button Two: Deactivate

Button One is pressed two fields and a button appear

Field 1: From Number Field 2: To Number

Button: Activate

Field 1 should auto-populate with the number queried from DB. And should not be changeable. The reason to still have a field is just to make it explicit what is happening.

When the Activate Button is pressed execute some action with parameter as below.

CALLACTION = "Call Forwarding On"

PHONENUMBER = From Number (From Field 1)

TOLLNUMBER = To Number (From Field 2)

Button Two is pressed a prompt and two buttons appear.

Prompt: "Are you sure you would like to deactivate the <Telephone Number>?" Where <Telephone Number> is the number initially queried.

Button 1: Yes Button 2: No


LATEST TUTORIALS
APPROVED BY CLIENTS