Arnab Chakraborty has Published 3734 Articles

Python program to find probability of getting letter 'a' in some letters and k sized combinations

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:20:52

503 Views

Suppose we have an array with n different English letters. We also have another value k. We can select k different indices (1-indexed) with uniform distribution. We have to find the probability that at least one of the k indices selected will contain the letter 'a'.So, if the input is ... Read More

Python program to check whether we can pile up cubes or not

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:14:01

360 Views

Suppose we have an array nums containing size of n different cubes, they are placed horizontally. We have to make a pile of cubes vertically. The new cube should follow −if ith cube is on top of jth cube, then side length of jth one must be greater or equal ... Read More

Program to compute gcd of two numbers recursively in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:11:17

8K+ Views

Suppose we have two numbers a and b. We have to find the GCD of these two numbers in recursive way. To get the GCD we shall use the Euclidean algorithm.So, if the input is like a = 25 b = 45, then the output will be 5To solve this, ... Read More

Python program to find top three mostly occurred letters from company name

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:09:00

647 Views

Suppose we have a company name as string. We have to find the most common three characters from the company name and show them by following these rules −Pick most frequent three lettersSort them in descending orderIf the frequencies of some characters are same then take by their alphabetical orderSo, ... Read More

Program to find area of a polygon in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:07:29

3K+ Views

Suppose we have a list of ordered points represents a simple polygon endpoint on a 2D plane. We have to find the area of this polygon.So, if the input is like points = [(0, 0), (0, 5), (3, 5), (3, 0)], then the output will be 15.To solve this, we ... Read More

Python program to count pairs for consecutive elements

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:05:34

628 Views

Suppose we have a numeric string s contains few digits. The digits may occur multiple times. We have to return some pairs (digit, count) represents which digit has occurred consecutively how many times in s. To solve this problem we can use the groupby() function that comes under itertools library. ... Read More

Python program to count distinct words and count frequency of them

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:02:11

910 Views

Suppose we have a list of words. These words may occur multiple times. We have to show the frequencies of these words and count how many distinct words are there.So, if the input is like words = ["Book", "Sound", "Language", "Computer", "Book", "Language"], then the output will be (4, '2 ... Read More

Python program to find happiness by checking participation of elements into sets

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 07:56:58

380 Views

Suppose we have an array nums with n different integers. We also have two disjoint sets A and B. We have one happiness parameter which is set to 0 initially. We go through each integer i in nums. If i is in A then add happiness by 1 and if ... Read More

Program to check whether domain and range are forming function or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 07:56:35

539 Views

Suppose we have a list of data say x, represents a domain and a list of data y (size of y is same as size of x), represents a range. We have to check whether x -> y is a function or not. Here we are considering all elements in ... Read More

Python program to find angle between mid-point and base of a right angled triangle

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 07:54:39

2K+ Views

Suppose we have two sides of a right angled triangle, these sides are AB and BC. Consider the midpoint of hypotenuse AC is M. We have to find the angle between M and BC.So, if the input is like ab = 6 bc = 4, then the output will be ... Read More

Advertisements