Found 33676 Articles for Programming

Python Program to find out the number of sets greater than a given value

Arnab Chakraborty
Updated on 18-May-2021 06:16:33

322 Views

Suppose, we have an array containing several integer numbers. We find out all the contiguous subarrays from the given array of numbers and put it into another list. Now, we replace each subarray with the maximum element in that subarray. There is also a number k given to us, and we have to find out how many subarrays are now greater than the given number.So, if the input is like input_array = [5, 6, 7, 8], k = 7, then the output will be 4The contiguous subarrays from the given input array are: {5}, {6}, {7}, {8}, {5, 6}, {6, ... Read More

Python Program to find out the determinant of a given special matrix

Arnab Chakraborty
Updated on 18-May-2021 06:14:42

483 Views

Suppose, we have a tree with n vertices, where each vertex is labeled from 1 to n. The root of the tree has the label 1, and each vertex weights wi. Now a nxn matrix A is formed where A(x, y) = Wf(x, y) where f(x, y) is the least common predecessor of vertex x and y. We have to find out the determinant of matrix A. The edges of the matrix, weights, and the total number of vertices are given to us as input.So, if the input is like input_array = [[1, 2], [1, 3], [1, 4], [1, 5]], ... Read More

Python Program to find out the number of rooms in which a prize can be hidden

Arnab Chakraborty
Updated on 18-May-2021 06:12:25

504 Views

Suppose, in a game show there are 2n number of rooms that are arranged in a circle. In one of the rooms, there is a prize that the participants have to collect. The rooms are numbered from 1, 2, 3, ...., n, -n, -(n - 1), ...., -1. in a clockwise manner. Each room has a door and by that door, a different room can be visited. Every door has a marking x on it, which means another room is located at a distance of x from the current room. If the value of x is positive, then the door ... Read More

Python Program to find out the sum of values in hyperrectangle cells

Arnab Chakraborty
Updated on 18-May-2021 06:08:42

194 Views

A hyperrectangle is a rectangle that has k dimensions. Each dimension has a length that can be denoted as n1, n2, n3,....., nm. The hyperrectangle's cells are addressed as (p,q,r,...) and contain a value that is equivalent to gcd of (p,q,r,...). Here 1

Python Program to find out how many cubes are cut

Arnab Chakraborty
Updated on 18-May-2021 06:05:19

228 Views

Suppose, there are several cubes of dimensions a, b, and c, and using them a new box of dimension axbxc is created. a, b, and c are pairwise co-prime; gcd(a, b) = gcd(b, c) = gcd(c, d) = 1. We have to cut the box into two pieces with a single slice as shown in the picture. We have to find out if the box is cut this way, how many cubes are cut into two pieces. We are provided an array that contains the possible three dimensions, and we have to find out our answer from that.The cut is ... Read More

Python Program to find out how many times the balls will collide in a circular tube

Arnab Chakraborty
Updated on 18-May-2021 06:02:48

266 Views

Suppose, there are n balls in a circular tube. The tube is 100 meters long and initially, each ball in the tube is i meters away from a point that we call the starting point. Now the balls start to travel within the tube in a circular order in different directions. The balls travel 0.1 meters per second within the tube. When two balls meet at a point, a collision occurs and the balls change their direction of travel. If this process goes for a long time, let's say 10^9 + 6 seconds; we have to find out the number ... Read More

Python Program to find the number of operations to pack several metal bars in a container

Arnab Chakraborty
Updated on 18-May-2021 06:00:16

202 Views

Suppose, we are given the tasks to transport several metal bars of different sizes. But the transportation container is short in length, it can contain bars of length 1 only. We are provided n number of bars, and their lengths are given to us in a list. So, to fit all the bars in the container; we have to cut and divide all the bars so they are of unit sizes. Further, we fit all the bars into the container that cost us one operation. We have to find the number of operations we have to perform on the bars.So, ... Read More

Python Program to find out the price of a product after a number of days

Arnab Chakraborty
Updated on 18-May-2021 05:56:14

1K+ Views

Suppose, a person wants to buy a product of price x. But each passing day, the price of the product increases x times the price of the previous day. We have to find out the price of the product after y days since the person has made up his mind to purchase the product. If the price of the product is too much, then the answer is given as price modulo 10^9 + 7. The input is given in a list of pairs; the first value of the pair is the initial price x and the second value is y, ... Read More

Python Program to find out the number of matches in an array containing pairs of (base, number)

Arnab Chakraborty
Updated on 18-May-2021 05:52:17

361 Views

Suppose, we are given several different pairs in the format (x, y). Here the x signifies the base of a number and y signifies the number itself. In the list there are pairs that mean the same. We have to check the number of matches in the given number pairs. The given pairs can be redundant, and can also contain invalid base-number combinations.So, if the input is like num_inputs = 2, input_arr = [(10, 15), (8, 17)], then the output will be 1.The variable num_inputs specify the number of inputs, and the array input_arr lists the number pairs. Here if ... Read More

Python Program to find out the size of the bus that can contain all the friends in the group

Arnab Chakraborty
Updated on 18-May-2021 05:47:07

398 Views

Suppose, there are n number of student groups waiting to get back from their college to their home via the college bus. In each student group, there are m number of students. The student groups want to travel by bus without getting separated. They board the bus if and only if all the members of their group can get on the bus. Also, a group does not board the bus if their previous group has not boarded the bus or has already reached their destination. If we are given the number of groups and the number of students in each ... Read More

Advertisements