Python Forum
Product of maximum in first array and minimum in second
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Product of maximum in first array and minimum in second
#1
So I am practicing the following

Quote:Given two arrays of size N1 and N2 respectively, the task is to calculate the product of max element of first array and min element of second array.

https://practice.geeksforgeeks.org/probl...n-second/0

I was writing this program and got hung up on an error...

Wall
Quote:Traceback (most recent call last):
File "C:\Users\groundZero Admin\Documents\Python\arrayPracetice1.py", line 22, in <module>
y = A[i]
IndexError: list index out of range

#Given two arrays of size N1 and N2 respectively, the task is to 
#calculate the product of max element of first array and min
#element of second array.
#
#

A = [1, 50, 2, 7, 3, 8]
B = [1, 50, 2, 7, 3, 8, 75, 77, 0]

listALength = len(A)
listBLength = len(B)

#These print functions were used to test the len function on arrays during
#this study session. They're now commented out to make them inactive.
#print(listALength)
#print(listBLength)

#Take the length of the array - 1 to increment the list via a loop

x = A[0]
for i in A:
    y = A[i]
    if y > x:
        x = y

print(x)
Please help me! Thank you!
Reply


Messages In This Thread
Product of maximum in first array and minimum in second - by Thethispointer - Jan-19-2018, 05:32 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Information Showing trendline formula in a table per product Carlossxx 0 683 May-03-2023, 08:34 AM
Last Post: Carlossxx
  How to add product details in exe generated by pyinstaller arex786 1 8,519 Oct-10-2021, 11:00 AM
Last Post: Sran012
  How to get indices of minimum time difference Mekala 1 2,186 Nov-10-2020, 11:09 PM
Last Post: deanhystad
  How to get index of minimum element between 3 & 8 in list Mekala 2 2,549 Nov-10-2020, 12:56 PM
Last Post: DeaD_EyE
  Largest product in a grid (projecteuler problem11) tragical 1 2,301 Sep-14-2020, 01:03 PM
Last Post: Gribouillis
  Blending calculator from final product xerxes106 0 1,629 Dec-05-2019, 10:32 AM
Last Post: xerxes106
  Make dual vector dot-product more efficient technossomy 3 2,545 Nov-28-2019, 09:27 PM
Last Post: Gribouillis
  Finding MINIMUM number in a random list is not working Mona 5 3,089 Nov-18-2019, 07:27 PM
Last Post: ThomasL
  Delete minimum occurence in a string RavCOder 10 4,032 Nov-12-2019, 01:08 PM
Last Post: RavCOder
  Minimum size Amniote 8 3,863 Jul-10-2019, 02:58 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020