Arnab Chakraborty has Published 4452 Articles

Python program to count pairs for consecutive elements

Arnab Chakraborty

Arnab Chakraborty

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

370 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

696 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

205 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

354 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

2K+ 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

429 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

Python program to find score and name of winner of minion game

Arnab Chakraborty

Arnab Chakraborty

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

361 Views

Suppose there are two players Amal and Bimal. They are playing a game. The game rules are as follows −Both players have a same string s.Both of them have to make substrings using the letters of s.Bimal has to make words starting with consonants.Amal has to make words starting with ... Read More

Program to update list items by their absolute values in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 07:33:50

197 Views

Suppose we have a list of numbers called nums with positive and negative numbers. We have to update this list so that the final list will only hold the absolute value of each element.So, if the input is like nums = [5, -7, -6, 4, 6, -9, 3, -6, -2], ... Read More

Advertisements