PDF Google Drive Downloader v1.1


Report a problem

Content text Imp coding questions with solutions .pdf


2. Matrix with Highest Sum Take string input then form all possible mXm square matrix, and print the matrix with maximum sum. In case, two or more square matrix has maximum sum then print largest matrix followed by next largest matrix and so on. In case, more than one matrix has same size print in order of their occurrence. INPUT: 6, 3, 6, 20, 3, 6,-15, 3, 3 OUTPUT: 6 3 6 20 3 6 -15 3 3 6 3 6 20 6 20 3 6 Explanation:- 6 3 6 20 3 6 -> its sum is 35 and is order 3*3, -15 3 3 6 3 6 20 -> its sum is 35 and is order 2*2, 6 20 3 6 -> its sum is 35 and is order 2*2, import math instr=list(map(int, input().split(","))) m=2 result={} k=int(math.sqrt(len(instr))) s1=0 s1_a=[] L=[] while(m<=k): j=0 while(j<=len(instr)-(m*m)): matrix=[] i=j new_sum=0 while(i!=(m*m)+j): matrix.append(instr[i:i+m]) new_sum+=sum(instr[i:i+m]) i+=m #print(matrix)

sublist[-1].append(temp) else: if((len(sublist[-1]))>L): if(len(lsa)): lsa.pop() lsa.append(sublist[-1]) L = len(sublist[-1]) elif((len(sublist[-1]))==L): if(sublist[-1] not in lsa): lsa.append(sublist[-1]) L = len(sublist[-1]) count=0 l=i j+=1 print(min(lsa)) 4. Matrix with same consecutive number Given an inmatrix mxn matrix(m,n>3).You have to perform the following operations: i) Find the same consecutive numbers in the matrix either vertically, horizontally or diagonally such that atleast four consecutive nos. are there. ii) If there are more than one such set of numbers then print an integer outnum which is the minimum of such consecutive nos. iii) If no such no. exists print -1 Input: First line contains an integer m. Second m lines have n space separated integers (note: n was not given) Output: An integer outnum or -1 if no such nos. exists 5 1 7 8 9 5 4 2 5 7 9 4 5 2 6 8 7 9 2 2 1 4 2 7 6 2 1 1 1 1 1 4 5 -1 1 2 2 2 5 4 1 1 3 5 4 9 1 4 1 8 2 6 2 5 8 7 4 1 2 9 3 3 3 7 m = int(input()) if m<4: sys.exit("Wrong Input") matrix = [] n=0 for i in range(m): arr = list(map(int, input().split())) if(n

Related document

x
Report download errors
Report content



Download file quality is faulty:
Full name:
Email:
Comment
If you encounter an error, problem, .. or have any questions during the download process, please leave a comment below. Thank you.