Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 30 of 377

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

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 417 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

Program to find k partitions after truncating sentence using Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 158 Views

Suppose we have sentence s where some English words are present, that are separated by a single space with no leading or trailing spaces. We also have another value k. We have to find only the first k words after truncating.So, if the input is like s = "Coding challenges are really helpful for students" k = 5, then the output will be True (See the image)To solve this, we will follow these steps −words := split s by spacesjoin first k letters from words array by separating spaces and returnLet us see the following implementation to get better understanding ...

Read More

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

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 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

Program to find sign of the product of an array using Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 284 Views

Suppose we have an array called nums. We have to find sign of the multiplication result of all elements present in the array.So, if the input is like nums = [-2, 3, 6, -9, 2, -4], then the output will be Negative, as the multiplication result is -2592To solve this, we will follow these steps −zeroes := 0, negatives := 0for each i in nums, doif i is same as 0, thenzeroes := zeroes + 1if i < 0, thennegatives := negatives + 1if zeroes > 0 , thenreturn "Zero"otherwise when negatives mod 2 is same as 0, thenreturn "Positive"otherwise, ...

Read More

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

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 241 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 how many times the balls will collide in a circular tube

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 312 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 out how many cubes are cut

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 284 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

Program to find sum of digits in base K using Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 797 Views

Suppose we have a number n in decimal number system (base 10) have another value k, we have to find the sum of the digits of n after converting given number n from base 10 to base k. When we calculate digit sum, we will consider each digit as decimal (base 10) number.So, if the input is like n = 985 k = 8, then the output will be 12 because the number 985 in octal is 1731, so the digit sum is 1+7+3+1 = 12.To solve this, we will follow these steps −ans := 0while n >= k, doans ...

Read More

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

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 240 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

Read More

Program to replace all digits with characters using Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 3K+ Views

Suppose we have an alphanumeric string s that contains lowercase English letters in its even positions and digits in its odd positions. Consider an operation shift(c, x), where c is any character and x is a number (digit), this will find the xth character after c. So, for example, shift('p', 5) = 'u' and shift('a', 0) = 'a'. Now for every odd index i, we want to replace the digit s[i] with shift(s[i-1], s[i]). We have to find s after replacing all digits.So, if the input is like s = "a2b1d4f3h2", then the output will be "acbcdhfihj" becauseshift('a', 2) = ...

Read More
Showing 291–300 of 3,768 articles
« Prev 1 28 29 30 31 32 377 Next »
Advertisements