1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Digiron [165]
3 years ago
15

Sublist(xs, total)'

Computers and Technology
1 answer:
motikmotik3 years ago
5 0

Answer:

# ths functionfind a sub matrix from the list

def findSubMatrix(xs, startR, startC, size):

   # an empty list named data is initialized

   data = []

   for i in range(startR, startR+size):

       row = []

       for j in range(startC, startC+size):

           row.append(xs[i][j])

       data.append(row)

   return data

# this function find the sum of each list in the matrix

def FindSum(matrix):

   # s represent the sum and is initialized to 0

   s = 0

   # loop through the matrix

   # sum each list and add to s

   for m in matrix:

       s += sum(m)

   # the value of s is returned

   return s

# this function return a sublist

def sublist(xs, total):

   # length of entire list is assigned to r

   r = len(xs)

   # length of first list is assigned to c

   c = len(xs[0])

 

   # for loop that loop from 2 to least value between r and c

   for size in range(2, min(r, c) + 1):

       # None is first assigned to result

       result = None

       for startR in range(0, r-size+1):

          for startC in range(0, c-size+1):

               d = findSubMatrix(xs, startR, startC, size)

               # findSum is use to compute the sum of d

               s = FindSum(d)

               # if s is greater than total

               # and if result is None or the sum of result is less than s

               # d is assigned to result

               if s > total:

                   if result is None or FindSum(result) < s:

                       result = d

       # if result is not None, it is returned

       if result is not None:

           return result

   return None

# the sublist function is called having two parameter

# a list of list of integer and a total

print(sublist([[0,1,2], [-4,5,6], [7,8,3]], 5))

print(sublist([[0,1,2], [-4,5,6], [7,8,3]], 23))

Explanation:

The program is written in Python and well commented. An image showing the output of the program when executed is attached.

You might be interested in
The names of the governing body or organizationds that creates rules for information technology and information communication te
IceJOKER [234]

Answer:

Alliance for Telecommunications Industry Solutions

Explanation:

Alliance for Telecommunications Industry Solutions  is the main body that creates rules for information technology and information communication technology.

This agency create solutions to supports the release of new products and services into the communications marketplace. It also act as an agency that standardizes the  wireless and wireline networks activities. It is accredited by the American National Standards Institute (ANSI).

5 0
3 years ago
Which part of the cpu accepts data?
V125BC [204]

The answer is the Processor register.

5 0
3 years ago
Why are visually interesting effects, such as WordArt, to be used sparingly?
mrs_skeptik [129]

Explanation:

<em>Formatting</em><em> </em><em>with</em><em> </em><em>Word</em><em> </em><em>Art</em><em> </em>

<em>Standard</em><em> </em><em>formatting</em><em> </em><em>options</em><em>,</em><em> </em><em>such</em><em> </em><em>as</em><em> </em><em>bold</em><em>,</em><em> </em><em>italic</em><em>,</em><em> </em><em>and</em><em> </em><em>underline</em><em> </em><em>,</em><em> </em><em>are</em><em> </em><em>all</em><em> </em><em>Available</em><em> </em><em>on</em><em> </em><em>the</em><em> </em><em>home tab</em><em>.</em><em> </em>

<em>Word</em><em> </em><em>Art</em><em> </em><em>Styles</em><em> </em>

<em>You</em><em> </em><em>can</em><em> </em><em>find</em><em> </em><em>Word</em><em> </em><em>art</em><em> </em><em>text</em><em> </em><em>effects</em><em> </em><em>in</em><em> </em><em>the</em><em> </em><em>text</em><em> </em><em>group</em><em> </em><em>on</em><em> </em><em>the</em><em> </em><em>insert</em><em> </em><em>tab</em><em>.</em><em> </em><em>When</em><em> </em><em>you</em><em> </em><em>apply</em><em> </em><em>a</em><em> </em><em>word</em><em> </em><em>art</em><em> </em><em>text</em><em> </em><em>effect</em><em> </em><em> </em><em>,</em><em> </em><em>PowerPoint</em><em> </em><em> </em><em>2</em><em>0</em><em>0</em><em>7</em><em> </em><em>displays</em><em> </em><em>the</em><em> </em><em>format</em><em> </em><em>contextual</em><em> </em><em>tab</em><em> </em><em>under</em><em> </em><em>drawing</em><em> </em><em>tools</em><em>.</em><em> </em>

8 0
3 years ago
Read 2 more answers
Name a network device which would have to be
VMariaS [17]

Answer:

network interface card (NIC).

4 0
3 years ago
Which number is equivalent to 17e3?<br><br> 17000.0<br> 1700.0<br> 0.017<br> 0.17
Nina [5.8K]

Answer:

17000.0

Explanation:

since it is a positive 3 you move the decimal 3 times to the right

8 0
3 years ago
Other questions:
  • A network administrator wants to have the same network mask for all networks at a particular small site. The site has the follow
    11·1 answer
  • For each of the following data storage needs, describe which abstract data types you would suggest using. Natural choices would
    15·1 answer
  • The first electronic networking technology widely used in the United States was the:
    6·1 answer
  • Send answer below, Thank you
    8·1 answer
  • How are natural systems and engineered systems similar to one another?
    8·1 answer
  • Write a short program that uses a for loop to write the numbers 1 through 10 to a file
    11·1 answer
  • What is the name of the worm that was written in 1988 that could replicate itself across computers on the internet?
    7·1 answer
  • How can using Prezi software for a presentation allow the presenter to better respond to audience needs?
    10·1 answer
  • What is the main difference between weathering, erosion and leaching​
    9·1 answer
  • Where do the projection lines converge in a perspective sketch?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!