Found 26504 Articles for Server Side Programming

Python Program to check if two sentences can be made the same by rearranging the words

Shubham Vora
Updated on 18-Aug-2023 18:11:12

212 Views

In this problem, we need to check whether we can make two strings equal by rearranging the words of the string. We will learn three different approaches to solving the problem. In the first approach, we will use a dictionary. In the second approach, we will use the sort() method, and in the third approach, we will use the counter() constructor, which is used to count the hashable objects in the python. Problem statement – We have given a str1 and str2 containing sentences. We need to check whether we can make both strings equal by rearranging the words of ... Read More

Sort an array of strings by replacements with their GCD with elements from another array

Shubham Vora
Updated on 18-Aug-2023 17:39:34

121 Views

In this problem, we have given two arrays of strings. We need to replace array1’s values to sort array1. To replace the values of array1, we can take the GCD of the current string of array1 with any string of array2. The GCD of the string is very similar to the GCD of the number. To solve the problem, we can find a GCD string lexicographically larger than the GCD of the string at the ith index in array1 and the jth index in array2. Problem statement – We have given array1 and array2 containing the strings, and the length ... Read More

Modify characters of a string by adding integer values of same-indexed characters from another given string

Shubham Vora
Updated on 18-Aug-2023 17:38:30

202 Views

In this problem, we need to modify the given string by adding the value of the digit from the num string to the ASCII value of str’s character. To solve the problem, we can convert the digit character to the actual digit and add it to the ASCII value of the character. If the ASCII value becomes greater than 122, we start again from 97. Problem statement – We have given two strings of the same length equal to N. The first string, named str, contains the lowercase alphabetical characters, and the second string, named num, contains digits only. ... Read More

Modify array by removing characters from their Hexadecimal representations which are present in a given string

Shubham Vora
Updated on 18-Aug-2023 15:15:38

134 Views

We have given an array of positive integers and need to modify each element of the array by removing the characters given the ‘hex’ string from the hexadecimal representation of the current element. To solve the problem, we can convert the current number to a hexadecimal number. After that, we can remove the characters from the hexadecimal string, which are common in ‘hex’ and the current hexadecimal string. After modifying the hexadecimal string, we can convert it back to decimal. Problem statement – We have given an array containing positive integers, and the array's length is N. Also, we ... Read More

Modify a Binary String by flipping characters such that any pair of indices consisting of 1s are neither co-prime nor divisible by each other

Shubham Vora
Updated on 18-Aug-2023 15:14:22

158 Views

In this problem, we have given a binary string of length 4*N, and we need to flip zeros of the binary string so that any pair of indices containing ‘1’ should not be co-prime or divisible by each other. Here, we can solve the problem by observation. The string contains 4*N characters. We can flip the N characters from the last, which are at the even index. Problem statement – We have given an integer N and a binary string of the length 4*N containing all zeros initially. We need to flip ‘0’ to ‘1’ in such a way so ... Read More

Find the text of the given tag using BeautifulSoup

Atharva Shah
Updated on 21-Aug-2023 16:10:10

5K+ Views

BeautifulSoup is a powerful tool that makes it easy to extract information from HTML and XML documents primarily developed in Python for the purpose of web scraping and web data extraction. One of the most useful features of BeautifulSoup is the ability to find specific tags within a document. In this blog, we will explore how to use BeautifulSoup to find the text of a given tag along with a few examples. Installation and Syntax Installing BeautifulSoup is necessary before using it so use the Python package manager and run the following command right inside your terminal. pip install beautifulsoup4 ... Read More

Find the sum and product of a NumPy array elements

Atharva Shah
Updated on 21-Aug-2023 15:13:05

564 Views

A Python package called NumPy is employed in scientific computing and to handle large-scale numerical data. It provides support for multi-dimensional arrays and matrices, as well as a large library of mathematical functions to manipulate them. In this tutorial, we will focus on two of the most commonly used NumPy functions: sum() and prod(). These functions are used to calculate the sum and product of all the elements in a NumPy array, respectively. Installation Get the numpy package installed using pip inside your terminal pip install numpy Import it as highlighted after successful installation − import numpy as np ... Read More

How to add Site Header, Site Title, Index Title in a Django Project?

Atharva Shah
Updated on 21-Aug-2023 15:10:42

823 Views

To make it simple for people to browse and comprehend the goal of the site, it's critical to have a clear and succinct site header, site title, and index title when constructing a Django project. You must specify the site header, site title, and index title in your Django application's HTML templates in order to add them to the site. Every page of your website will have these components, making it simpler for visitors to browse and comprehend the goal of your project. These additions are especially helpful for complicated, huge websites that users may have trouble navigating. We will ... Read More

How to add RSS Feed and Sitemap to Django project?

Atharva Shah
Updated on 21-Aug-2023 15:09:35

185 Views

Introduction The incorporation of web components like Sitemaps and RSS (Really Simple Syndication) Feeds can provide a multitude of benefits such as enhancing user accessibility, augmenting website content consumption, and improving search engine performance. Developers can leverage Django to streamline the process of constructing web applications, resulting in the creation of websites that are exceptionally effective and user-friendly. What is RSS and Sitemap? RSS Feeds are XML files that include summaries of the material on a website, like article headlines and descriptions. Users may simply get the material without visiting the website by reading these files using RSS readers. On ... Read More

Toggle First and Last Bits of a Number

Vanshika Sood
Updated on 17-Aug-2023 20:02:03

848 Views

The following article provides an in depth explanation of the method used to modify a number by toggling its first and last bit using bitwise operators. A bitwise operator is an operator that can be used to manipulate individual bits in binary numbers or bit patterns. Problem Statement For a given number n, modify the number such that the first and the last bit of the binary expansion of the new number are flipped i.e. if the original bit is 1 then the flipped bit should be 0 and vice versa. All the bits between the first and the last ... Read More

Advertisements