Posts

Staircase Challenge Solution in Python

Consider a staircase of size  : # ## ### #### Observe that its base and height are both equal to  , and the image is drawn using  #  symbols and spaces.  The last line is not preceded by any spaces. Write a program that prints a staircase of size  . Function Description Complete the  staircase  function in the editor below. It should print a staircase as described above. staircase has the following parameter(s): n : an integer Input Format A single integer,  , denoting the size of the staircase. Constraints  . Output Format Print a staircase of size   using  #  symbols and spaces. Note : The last line must have   spaces in it. Sample Input 6 Sample Output # ## ### #### ##### ###### Explanation The staircase is right-aligned, composed of  #  symbols and spaces, and has a height and width...

Plus Minus Solution in Python

Given an array of integers, calculate the fractions of its elements that are  positive ,  negative , and are  zeros . Print the decimal value of each fraction on a new line. Note:  This challenge introduces precision problems. The test cases are scaled to six decimal places, though answers with absolute error of up to   are acceptable. For example, given the array   there are   elements, two positive, two negative and one zero. Their ratios would be  ,   and  . It should be printed as 0.400000 0.400000 0.200000 Function Description Complete the  plusMinus  function in the editor below. It should print out the ratio of positive, negative and zero items in the array, each on a separate line rounded to six decimals. plusMinus has the following parameter(s): arr : an array of integers Input Format The first line contains an integer,  , denoting the size of the array.  The...