Arnab Chakraborty has Published 4173 Articles

Program to find perimeter of a polygon in Python

Arnab Chakraborty

Arnab Chakraborty

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

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

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

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

610 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

495 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

272 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

Python program to find better divisor of a number

Arnab Chakraborty

Arnab Chakraborty

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

488 Views

Suppose we have a number n. We have to find divisor of n which one is better based on these conditions: We have two numbers p and q, the one whose digits sum to a larger number is called better than the other one. When the sum of digits is ... Read More

Program to find length of a list without using built-in length() function in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 07:31:13

821 Views

Suppose we have a list nums. We have to find the length of this list but without using any length(), size() or len() type of functions.So, if the input is like nums = [5, 7, 6, 4, 6, 9, 3, 6, 2], then the output will be 9.To solve this, ... Read More

Advertisements