Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 128 of 377

camelCase in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 9K+ Views

CamelCase is a naming convention where the first word starts with a lowercase letter and each subsequent word starts with an uppercase letter, with no spaces between words. In Python, we can convert a list of words to camelCase format using string manipulation. So, if the input is like ["Hello", "World", "Python", "Programming"], then the output will be "helloWorldPythonProgramming". Algorithm Steps To solve this, we will follow these steps − Initialize an empty string For each word in the list − ...

Read More

Caesar Cipher in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 1K+ Views

The Caesar Cipher is a simple encryption technique where each letter in a string is shifted by a fixed number of positions in the alphabet. When a letter goes past 'z', it wraps around to 'a'. For example, if we have the string "hello" and shift by 3 positions, 'h' becomes 'k', 'e' becomes 'h', and so on, resulting in "khoor". Algorithm Steps To implement the Caesar cipher, we follow these steps ? Convert each character to its position in the alphabet (0-25) Add the shift value ...

Read More

Buying Cars in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 448 Views

Suppose we have a list of prices of cars for sale, and we also have a budget k, we have to find the maximum number of cars we can buy. So, if the input is like [80, 20, 10, 30, 80], k = 85, then the output will be 3 as we can buy three cars with prices 20, 10, 30. Algorithm To solve this, we will follow these steps − Initialize count := 0 Sort the list of prices in ascending order For i in range 0 to size of prices, do If prices[i]

Read More

Boss Fight in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 744 Views

In this problem, we have a fighters list representing fighters (where 1 = fighter) and a bosses matrix where each row represents a boss formation (where 1 = boss). Fighters can defeat a boss row only if they have more fighters than that boss row has bosses. We need to return the remaining undefeated boss rows. Problem Understanding Given fighters = [0, 1, 1] (2 fighters total) and the boss matrix: Boss Matrix: [0, 0, 0] → 0 bosses (defeated: 2 > 0) ...

Read More

Book Pagination in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 1K+ Views

Book pagination is a common requirement when displaying large amounts of text content in manageable chunks. In Python, we can implement pagination by calculating the starting index based on the page number and page size, then extracting the appropriate slice of data. Given a list of strings representing a book, a page index (0-indexed), and a page size, we need to return the list of words on that specific page. If the page is out of bounds, we return an empty list. Problem Example If we have: book = ["hello", "world", "programming", "language", "python", "c++", "java"] ...

Read More

Bob's Game in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 743 Views

Suppose we have a friend named Bob, and he is playing a game with himself. He gives himself a list of numbers called nums. Now in each turn, Bob selects two elements of the list and replaces them with one positive integer with the same sum as the numbers he selected. Bob declares victory when all of the numbers in the array are even. We have to find the minimum number of turns required by Bob so he can declare victory. If there is no such solution, then return -1. So, if the input is like [2, 3, 4, ...

Read More

Big Numbers in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 457 Views

In Python, working with big numbers (arbitrary precision integers) is seamless because Python automatically handles integers of any size. Unlike many other programming languages that have fixed-size integer types, Python's int type can grow as large as your system's memory allows. Python's Built-in Big Number Support Python automatically converts integers to arbitrary precision when they exceed the typical 32-bit or 64-bit limits ? # Large numbers are handled automatically big_number = 12345678901234567890123456789 print("Big number:", big_number) print("Type:", type(big_number)) # Arithmetic operations work seamlessly result = big_number * 999999999999999999999 print("Multiplication result:", result) Big number: ...

Read More

Base 3 to integer in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 1K+ Views

Converting a base 3 number to decimal involves multiplying each digit by the appropriate power of 3. Python provides several methods to perform this conversion efficiently. Understanding Base 3 to Decimal Conversion In base 3, each digit position represents a power of 3. For example, "10122" in base 3 equals: 1×3⁴ + 0×3³ + 1×3² + 2×3¹ + 2×3⁰ = 81 + 0 + 9 + 6 + 2 = 98 Method 1: Using Horner's Method This efficient algorithm processes digits from left to right, accumulating the result ? def base3_to_decimal(s): ...

Read More

Austin Powers in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 149 Views

Suppose we have a number greater than 0, we have to check whether the number is a power of two or not. A power of two is any number that can be expressed as 2n where n is a non-negative integer (1, 2, 4, 8, 16, 32, etc.). So, if the input is like 1024, then the output will be True because 1024 = 210. Approach To solve this, we will follow these steps ? While n > 1, do n := n / 2 Return true when n is same as ...

Read More

Atbash cipher in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 3K+ Views

The Atbash cipher is a simple substitution cipher where each letter is mapped to its reverse position in the alphabet. In this cipher, 'a' becomes 'z', 'b' becomes 'y', and so on. Let's explore how to implement this cipher in Python. Understanding the Atbash Cipher The Atbash cipher works by reversing the alphabet: Original: a b c d e f g h i j k l m n o p q r s t u v w x y z Atbash: z y x w v u t s r q p o n m ...

Read More
Showing 1271–1280 of 3,768 articles
« Prev 1 126 127 128 129 130 377 Next »
Advertisements