1 answer

Please help with Python code. testing for: def pyramid_blocks_generator(seed): n = 300 ns = it.islice(scale_random(seed, 3,...

Question:

Please help with Python code.

def pyramid_blocks (n, m, h): A solid pyramid structure (although here in the ancient Mesoamerican than the more famous ancie

testing for:

def pyramid_blocks_generator(seed):
n = 300
ns = it.islice(scale_random(seed, 3, 10), n)
ms = it.islice(scale_random(seed + 1, 3, 10), n)
hs = it.islice(scale_random(seed + 2, 2, 15), n)
yield from zip(ns, ms, hs)

def pyramid_blocks (n, m, h): A solid pyramid structure (although here in the ancient Mesoamerican than the more famous ancient Egyptian style) is built from layers, each layer consisting of a rectangle of identical cubic blocks. The top layer of the pyramid consists of n rows and m columns of such blocks. The layer immediately below each layer contains one more row and one more column, all the way to the bottom layer of the pyramid. If the entire pyramid consists of h such layers, how many blocks does this pyramid contain in total? Here you can solve this problem in a straightforward fashion by simply looping through the h layers and adding up all the blocks along the way in each layer. However, if you happen to know some discrete math and combinatorics, you can come up with an analytical closed form formula for the result and compute the answers much faster that way. (There is an important general principle in this for you to later ponder on your own once you have done more of these problems.) n h Expected result 2 3 1 6 2 3 10 570 10 11 12 3212 100 100 100 2318350 10**6 10**6 10**6 2333331833333500000

Answers

Solution : This is program to fine total blocks required in 3D pyramid. where

n = X (bredth)

m =Y (length)

h =Z (height)

any layer contains total of n*m blockes and next layer will contains one more element in X and Y direction so the next layer contain (n+1)*(m+1)

so we can say that let first layer be L(k1) elements

L(k1) = n*m

L(k2) = (n+1)*(m+1)

L(k3) = (n+2)*(m+2)

...

...

L(kh) = (n+h-1)*(m+h-1)

and the answer will be sum of all the blocks

i.e Total_bocks = L(k1)+L(k2)+L(k3)...+L(kn)

_________________________________________________________

MATHEMATICALLY

bym y (h-l) ter blocks = first layer & and layer pth layer +(1+1)(mt) + (0+2)(2012) ..(n+h) (mth-1) NXM + um ti (nem JH+ 10 4

___________________________________________________________

FUNCTON DEFINITION IN PYTHON

############################################################

def pyramid_fast(n,m,h):
blocks = (n*h*m +(h*(h-1)//2)*(n+m)+(2*h-1)*h*(h-1)//6)
return blocks
############################################################

def pyramid(n,m,h): blocks = 0 for i in range(h): blocks+=n*m n+=1 m+=1 return blocks #function decleration take three variab

OUT

n = RESTART: /home/deeplearningcv/Documents/number_of_pyramid_block.py n = 2,m = 3, h = 1 : 66 2,m = 3, h = 10 : 570 570 n =

.

Similar Solved Questions

1 answer
Problem Nine A test for a certain disease was given to 1,000 subjects, 8% of whom...
Problem Nine A test for a certain disease was given to 1,000 subjects, 8% of whom were known to have the disease. For the subjects who had the disease, the test had a positive result for the disease in 90% of the subjects, was inconclusive for 7% and a negative result in 3% of the subjects. For subj...
1 answer
APPLYING YOUR KNOWLEDGE: A group of Santa Fe College students is studying the effects of forest...
APPLYING YOUR KNOWLEDGE: A group of Santa Fe College students is studying the effects of forest canopy cover on understory plant growth in North Woods located across the street from SF College. Using what you learned in the lab about photosynthesis, design an experiment that measures the effect of c...
1 answer
A + 2B-30 Experiment Number [A] (M) [B] (M) Initial Rate (M/s) 1 0.112 0.58 0.87...
A + 2B-30 Experiment Number [A] (M) [B] (M) Initial Rate (M/s) 1 0.112 0.58 0.87 2 0.112 1.16 1.74 3 0.560 0.58 21.75 The rate law for this reaction is rate ОА. k[A]2[B] O B. [P] Ock[A][B] OD [A]2 O E k[A]2[B]2...
1 answer
16. The patient has an order for oxytocin (Pitocin) to infuse at 15 mu/minute. Available is...
16. The patient has an order for oxytocin (Pitocin) to infuse at 15 mu/minute. Available is oxytocin 10 units/1000 mL 0.9% NaCl. At what rate will the nurse set the infusion? ___ mL/hr (If needed, round to the nearest whole number.) How do you set this up using dimensional analysis please?...
1 answer
RTR Inc.'s sales last year were $2,750,000 (all on credit), and its net profit margin was...
RTR Inc.'s sales last year were $2,750,000 (all on credit), and its net profit margin was 12%. Its inventory turnover was 5.0 times during the year, and its days sales outstanding was 32 days. Its annual cost of goods sold was $2,200,000. The firm had fixed assets totaling $800,000. RTR's pa...
1 answer
Categorize each phrase below as being relevant to ionic bonding, covalent bonding or metallic bonding. molecular...
Categorize each phrase below as being relevant to ionic bonding, covalent bonding or metallic bonding. molecular formula electron-sea model nonmetal with nonmetal electron sharing three-dimensional array separate molecules electron transfer metal with nonmetal electron pooling empirical formula allo...
1 answer
An array antenna consists of two identical half-wave dipole antenna elements. The array operates in air...
An array antenna consists of two identical half-wave dipole antenna elements. The array operates in air at 100 MHz. User A is in the azimuth plane of the array, on a line that makes 60° with the line defined by the antenna elements. The driving current has no phase shift. What is the shortest ph...
1 answer
Q21 In this phase of the business cycle, most businesses appear to be highly profitable. Trough...
Q21 In this phase of the business cycle, most businesses appear to be highly profitable. Trough Recession Recovery Boom...
1 answer
Blasius equation for turbulent flow f = 0.316Red-1/4 holds good only when the Reynolds number is...
Blasius equation for turbulent flow f = 0.316Red-1/4 holds good only when the Reynolds number is in the range ____________....
1 answer
In the circuit given below, R-90 . Find the value of Vab and io using mesh...
In the circuit given below, R-90 . Find the value of Vab and io using mesh analysis. 20 2 lo 30 2 80 V+ 20 2 0Vab 80 V + 30 2 The value of io in the circuit is 0.966 A. The value of Vab in the circuit is 28.98 V....
1 answer
An eCommerce website displays the content slightly differently depending on the device used to access the website. Suppose the website manager knows that the proportion of customers who access the website using a smartphone is 0.62.
The website manager wants to collect a sample such that the standard deviation of the sample proportion is less than 0.02. What is the minimum sample size required to satisfy this criterion?Note:1- Round any intermediate numbers to 4 decimal places.2- Round your final answer ...
1 answer
Two blocks are pushed along a frictionless surface. The static coefficient of friction between the blocks...
Two blocks are pushed along a frictionless surface. The static coefficient of friction between the blocks is .70 mm is the maximum force F that can be applied to the lower block (as shown on the diagram) Such that the upper block does not slide...
1 answer
2 methods of data collection for population health problem CLABSI
2 methods of data collection for population health problem CLABSI...
1 answer
Business Law II Ch. 33- Agency Formation and Duties Professor Shane J. Egan Name Date 5....
Business Law II Ch. 33- Agency Formation and Duties Professor Shane J. Egan Name Date 5. An agency formed by making a written or oral agreement which clearly defines the scope of the relationship is known as an 6. ( True False) An agency formed by implication through the conduct of the parties is kn...
1 answer
25. What is the probability that a randomly chosen car purchase was a Hybrid purchased by...
25. What is the probability that a randomly chosen car purchase was a Hybrid purchased by a female given that an SUV was purcha: ? (Don't worry about decimal representation or reducing fractions.) a) 42/156 b) 42/240 c) 42/180 d) 47/180 e) None of the above VII. USE THE INFORMATION BELOW TO ANSW...
1 answer
Thumbs up for good answer. Why does the liquid in the round bottom flask turn light...
Thumbs up for good answer. Why does the liquid in the round bottom flask turn light pink?, please explain (This happened during/after step 2). This is the procedure and the experiment is called Synthesis of Artificial Flavorings by Fischer Esterification. Thank you! SAMPLE PROCEDURES: 1. Isoanvl ace...
1 answer
Prepare the summary entries necessary to determine the amount of cash received from customers for each...
Prepare the summary entries necessary to determine the amount of cash received from customers for each of the four independent situations below.    Situation Sales revenue Accounts receivable Increase (Decrease) Cash received from customers 1 $ 280,000    $ 10,800  &nb...
1 answer
Please show detailed work. Do all of number 3. thanks a, which is a -괘 ste...
Please show detailed work. Do all of number 3. thanks a, which is a -괘 ste e right ., , "ith mass m and place it ar ponn end of the rod, how much potential energy of the system will el al meter of th ar b) 'ind the pericular orbit,rbit of radius r. The two stars are always at opposit...
1 answer
Which of the following statements is FALSE? Group of answer choices A large stock is typically...
Which of the following statements is FALSE? Group of answer choices A large stock is typically more volatile than a portfolio of large stocks. Investors would not choose to hold a portfolio that is more volatile unless they expected to earn a higher return. Smaller stocks have lower volatility than ...