Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone

HackerRank Sum and Prod problem solution in python

YASH PAL, 31 July 2024

In this Sum and Prod problem, You are given a 2-D array with dimensions N X M. Your task is to perform the sum tool over axis 0 and then find the products of that result.

HackerRank Sum and Prod solution in python

Problem solution in Python 2 programming.

import numpy
m=map(int,raw_input().split())
n=[]
for i in range(m[0]):
    n.append(map(int,raw_input().split()))

print numpy.prod(numpy.sum(n,axis=0))

Problem solution in Python 3 programming.

import numpy
N, M = map(int, input().split())
A = numpy.array([input().split() for _ in range(N)],int)
print(numpy.prod(numpy.sum(A, axis=0), axis=0))

Problem solution in pypy programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
import numpy
N, M = map(int, raw_input().split())
myarr = []
for _ in range(N): 
    myarr.append(map(int,raw_input().split()))
print numpy.prod(numpy.sum(myarr, axis = 0), axis = 0)

Problem solution in pypy3 programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
import functools

n, m = map(int, input().split())

a = []

for _ in range(n):
    a.append(list(map(int,input().split())))
    
#print(a)

b = [sum(x) for x in zip(*a)]

print(functools.reduce(lambda x,y: x*y, b))

coding problems solutions Python Solutions

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes