Yaswanth Varma

Yaswanth Varma

307 Articles Published

Articles by Yaswanth Varma

307 articles

Alternate Cycling in Python List

Yaswanth Varma
Yaswanth Varma
Updated on 27-Mar-2026 517 Views

Lists in Python are ordered collections that store and manipulate a sequence of elements. Alternate cycling is the process of accessing or iterating through list elements by skipping elements in a fixed pattern, typically every second element. What is Alternate Cycling? Alternate cycling allows you to extract elements at regular intervals from a list. Here's a simple example ? Input: [1, 2, 3, 4, 5, 6] Output: [1, 3, 5] Explanation: Starting from index 0, we take every second element. Using List Slicing Slicing is the most efficient way to perform alternate cycling ...

Read More

Analyze and Visualize Earthquake Data in Python with Matplotlib

Yaswanth Varma
Yaswanth Varma
Updated on 27-Mar-2026 939 Views

Earthquakes are natural phenomena that can have significant effects on human life and infrastructure. With the availability of geospatial and seismic datasets, scientists and researchers can analyze and visualize earthquake data to identify patterns, trends, and risk zones. Python, along with libraries like Matplotlib, Pandas, and NumPy, provides powerful tools to process and visualize this data. In this article, we will analyze and visualize earthquake data in Python with Matplotlib. Dataset Overview For the examples in this article, we use a dataset that contains information about earthquakes. The data is stored in rows and columns, where each ...

Read More

Check if all rows of a matrix are circular rotations of each other in Python

Yaswanth Varma
Yaswanth Varma
Updated on 25-Mar-2026 272 Views

Matrices are used to represent and manipulate structured data (such as grids, patterns). While working with matrix manipulation, we may find scenarios where we need to determine whether all the rows in a given matrix are circular rotations of one another. Circular Rotation in a Matrix A circular rotation of a row (or array) is a transformation where elements are shifted to the left (or right), and the element at the end wraps around to the beginning. For example, if the original row is [1, 2, 3], its circular rotations are ? ...

Read More

Check if array contains contiguous integers with duplicates allowed in Python

Yaswanth Varma
Yaswanth Varma
Updated on 25-Mar-2026 595 Views

A sequence of numbers is said to be contiguous if the numbers can be arranged in such a way that each number follows the previous one without any gaps. For example, [11, 12, 13, 14] is a contiguous sequence because there are no missing numbers between the smallest and largest values. In this article, we need to check if an array contains such contiguous integers, even when duplicates are present. For instance, [11, 12, 13, 13, 14] should still be considered contiguous because the unique numbers are [11, 12, 13, 14], which form a proper sequence without breaks. ...

Read More

Check if array can be sorted with one swap in Python

Yaswanth Varma
Yaswanth Varma
Updated on 25-Mar-2026 424 Views

Sorting is a task used to organize numbers in increasing order. Usually, we use sorting algorithms to do this, but in most cases, the array is almost sorted, with only two or three numbers in the wrong position. In such scenarios, instead of sorting the entire array, we can check if swapping just one pair of elements will make the entire array sorted. Problem Definition Given an array with distinct integers, we need to find if it can become completely sorted by swapping only one pair of elements. We are not performing the swap, just checking if ...

Read More

Check if array can be divided into two sub-arrays such that their absolute difference is Ks in Python

Yaswanth Varma
Yaswanth Varma
Updated on 25-Mar-2026 199 Views

In this article we are going to check whether the given array can be divided into two sub-arrays in such a way that the absolute difference between the sums of these two sub-arrays is equal to the given value k. The absolute difference is nothing but the non-negative gap between two numbers, calculated as abs(sum1-sum2). In this task the split must produce two non-empty sub-arrays i.e. at least one element should be present in each part. Example Scenarios Following are the example scenarios: Scenario 1 Input: array = [3, 1, 4, 2, 2], K ...

Read More

Check if any square (with one colored cell) can be divided into two equal parts in Python

Yaswanth Varma
Yaswanth Varma
Updated on 25-Mar-2026 268 Views

In this article, we are given a square of size n×n with exactly one cell colored. The task is to determine whether this square can be divided into two equal parts by making a single straight cut, ensuring that the colored cell lies entirely within one of the parts. Two equal parts means both splits must contain the same number of cells, which is only possible if the square side length is even. We need to check if the position of the colored cell allows such a split without being intersected by the cut. Understanding the Problem ...

Read More

Check if any permutation of a number is divisible by 3 and is Palindromic in Python

Yaswanth Varma
Yaswanth Varma
Updated on 25-Mar-2026 299 Views

This task involves checking if any permutation of a given number's digits can form a new number that is both divisible by 3 and palindromic. A number is divisible by 3 if the sum of its digits is divisible by 3, and a number is palindromic if it reads the same forwards and backwards. Understanding the Problem For a number to be divisible by 3, the sum of its digits must be divisible by 3. For it to be palindromic, the number must read the same when reversed. We need to check if any permutation of the input ...

Read More

Check if any permutation of a large number is divisible by 8 in Python

Yaswanth Varma
Yaswanth Varma
Updated on 25-Mar-2026 1K+ Views

A number is divisible by 8 if its last three digits form a number divisible by 8. For large numbers, checking all permutations is impractical, but we can use this divisibility rule to efficiently check if any permutation is divisible by 8. Divisibility Rule for 8 According to the divisibility rule of 8, if the last three digits of a number are divisible by 8, then the entire number is divisible by 8. We can solve this problem by checking if we can form any three-digit combination from the given digits that is divisible by 8. Examples ...

Read More

Check if any large number is divisible by 19 or not in Python

Yaswanth Varma
Yaswanth Varma
Updated on 25-Mar-2026 489 Views

In mathematics, divisibility helps us determine whether a number can be divided by another without leaving a remainder. For example, 6 is divisible by 2 because 6/2 = 3 with no remainder. In this article, we will learn how to check if any large number is divisible by 19 in Python using the modulus operator. Why Python Handles Large Numbers Well Checking divisibility with small numbers is straightforward using standard arithmetic operations. However, when dealing with very large numbers (containing 20, 30, or even 100 digits), many programming languages encounter issues due to integer size limits. ...

Read More
Showing 1–10 of 307 articles
« Prev 1 2 3 4 5 31 Next »
Advertisements