Found 33676 Articles for Programming

Multiply one Laguerre series to another in Python

AmitDiwan
Updated on 03-Mar-2022 06:27:24

141 Views

To multiply one Laguerre series to another, use the polynomial.laguerre.lagmul() method in Python Numpy. Returns the multiplication of two Laguerre series c1 * c2. The sequences of coefficients are from lowest order term to highest, i.e., [1, 2, 3] represents the series P_0 + 2*P_1 + 3*P_2. The parameters c1 and c2 are 1-D arrays of Laguerre series coefficients ordered from low to high.StepsAt first, import the required library −import numpy as np from numpy.polynomial import laguerre as LCreate 1-D arrays of Laguerre series coefficients −c1 = np.array([1, 2, 3]) c2 = np.array([3, 2, 1])Display the arrays of coefficients −print("Array1...", ... Read More

C++ program to find maximum how many chocolates we can buy with at most k rupees

Arnab Chakraborty
Updated on 03-Mar-2022 06:28:13

468 Views

Suppose we have an array A with n elements, and other values l, r and k are there. Amal wants to buy chocolates and he will not buy too expensive chocolates, and not also too cheap chocolates. In the store, there are n different chocolate bars and the prices are represented in A. A chocolate bar is too expensive if its price is larger than r and too cheap if its price is less than l. He wants to spend at most k rupees. We have to find the maximum amount of chocolates he can buy.So, if the input is ... Read More

Multiply a Laguerre series by an independent variable in Python

AmitDiwan
Updated on 03-Mar-2022 06:25:28

112 Views

To multiply a Laguerre series by an independent variable, use the polynomial.laguerre.lagmulx() method in Python. Multiply the Laguerre series c by x, where x is the independent variable. The parameter c is a 1-D array of Laguerre series coefficients ordered from low to high.StepsAt first, import the required library −import numpy as np from numpy.polynomial import laguerre as LCreate an array −c = np.array([1, 2, 3])Display the array −print("Our Array...", c)Check the Dimensions −print("Dimensions of our Array...", c.ndim)Get the Datatype −print("Datatype of our Array object...", c.dtype)Get the Shape −print("Shape of our Array object...", c.shape)To multiply a Laguerre series by an ... Read More

C++ program to count number of steps needed to make sum and the product different from zero

Arnab Chakraborty
Updated on 03-Mar-2022 06:24:13

299 Views

Suppose we have an array A with n elements. In one operation, we can add 1 with any one element preset in A. If either the sum or the product of all elements in the array is equal to zero, We can do this operation one more time. We have to count the minimum number of steps needed to make both the sum and the product of all elements in the array different from zero?So, if the input is like A = [-1, 0, 0, 1], then the output will be 2, because both product and sum are 0. If ... Read More

Subtract one Laguerre series from another in Python

AmitDiwan
Updated on 03-Mar-2022 06:23:27

127 Views

To subtract one Laguerre series from another, use the polynomial.laguerre.lagsub() method in Python Numpy. The method returns an array of Laguerre series coefficients representing their difference. Returns the difference of two Laguerre series c1 - c2. The sequences of coefficients are from lowest order term to highest, i.e., [1, 2, 3] represents the series P_0 + 2*P_1 + 3*P_2. The parameters c1 and c2 are 1-D arrays of Laguerre series coefficients ordered from low to high.StepsAt first, import the required library −import numpy as np from numpy.polynomial import laguerre as LCreate 1-D arrays of Laguerre series coefficients −c1 = np.array([1, ... Read More

Generate a Pseudo Vandermonde matrix of the Hermite polynomial and x, y, z sample points in Python

AmitDiwan
Updated on 03-Mar-2022 06:19:47

178 Views

To generate a pseudo Vandermonde matrix of the Hermite polynomial and x, y, z sample points, use the hermite.hermvander3d() in Python Numpy. The method returns the pseudo-Vandermonde matrix. The parameter, x, y, z are arrays of point coordinates, all of the same shape. The dtypes will be converted to either float64 or complex128 depending on whether any of the elements are complex. Scalars are converted to 1-D arrays. The parameter, deg is the list of maximum degrees of the form [x_deg, y_deg, z_deg].StepsAt first, import the required library −import numpy as np from numpy.polynomial import hermite as HCreate arrays of ... Read More

C++ program to find maximum profit we can make by making hamburger and chicken burgers

Arnab Chakraborty
Updated on 03-Mar-2022 06:20:46

373 Views

Suppose we have five numbers b, p, f, h and c. There are two types of burgers in a restaurant. These are hamburger and chicken burger. Hamburger needs two buns and a beef patty and for chicken burger we need two buns and a chicken cutlet. We have b buns, p beef patties, f chicken cutlets. We are trying to sell hamburger for h rupees and chicken burger for c rupees. We have to find the maximum profit that we can gain.So, if the input is like b = 7; p = 5; f = 2; h = 10; c ... Read More

C++ program to check we can place dominos on colored cells in correct order or not

Arnab Chakraborty
Updated on 03-Mar-2022 06:17:10

169 Views

Suppose we have five numbers n, k1, k2, w and b. There is a board with 2 x n cells and first k1 cells in the first row, first k2 cells in second row are colored in white. All other cells are black. We have w white dominos and b black dominos (2 x 1 size). We can place a white domino on the board if both board's cells are white and not occupied by any other domino. In the same way, a black domino can be placed if both cells are black and not occupied by any other domino. ... Read More

C++ program to find number of groups can be formed from set of programmers

Arnab Chakraborty
Updated on 03-Mar-2022 06:12:58

448 Views

Suppose we have an array A with n elements. The A[i] represents the programming skill of ith student. All elements in A are distinct. We want to split them into teams in such a way that −No two students i and j, such that |A[i] - A[j]| = 1 belong to the same teamThe number of teams is the minimum possible.So, if the input is like A = [2, 3, 4, 99, 100], then the output will be 2, because the groups are [2, 3, 4] and [99, 100]StepsTo solve this, we will follow these steps −dem := 1 sort ... Read More

C++ program to find minimum possible number of keyboards are stolen

Arnab Chakraborty
Updated on 03-Mar-2022 06:09:53

566 Views

Suppose we have an array A with n elements. There was an electronic store, where a robbery has done on the last night. All keyboards which were present inside the store were numbered in ascending order from some integer number x. For example, for x=4 and there were 3 keyboards in the store, then the devices had indices 4, 5 and 6. If x=10 and there were 7 of them then the keyboards had indices 10, 11, 12, 13, 14, 15 and 16. After the robbery, only n keyboards are left. They have indices stored in array A. We have ... Read More

Advertisements