Arnab Chakraborty has Published 4293 Articles

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

Arnab Chakraborty

Arnab Chakraborty

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

607 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

568 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

873 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

Program to find perimeter of a polygon in Python

Arnab Chakraborty

Arnab Chakraborty

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

2K+ Views

Suppose we have a list of ordered points represents a simple polygon endpoint on a 2D plane. We have to find the perimeter of this polygon.So, if the input is like points = [(0, 0), (0, 5), (3, 5), (3, 0)], then the output will be 16 becausetwo sides are ... 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

333 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

496 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

Python program to find difference between two timestamps

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 07:49:03

3K+ Views

Suppose we have two times in this format "Day dd Mon yyyy hh:mm:ss +/-xxxx", where Day is three letter day whose first letter is in uppercase. Mon is the name of month in three letters and finally + or - xxxx represents the timezone for example +0530 indicates it is ... Read More

Python program to split string into k distinct partitions

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 07:42:07

570 Views

Suppose we have a string s and and a value k. The value of k is factor of the length of s, say the length is n. We can split s into n/k different substrings called t_i of size k. Then use these t_i to make u_i such thatThe characters ... Read More

Advertisements