Transposition Algorithm in Python (Expert Guide)

What is a Transposition Algorithm? A substitution algorithm, such as previously mentioned Caesar’s algorithm, works by substituting each symbol of the plaintext message with another symbol, according to a predetermined offset defined by a key. In contrast, a transposition algorithm shifts, or changes the positions of its symbols by following a specific, predetermined key. Since … Read more

Caesar Cipher in Python

Caesar Cipher is a simple encryption and obfuscation method. It’s a straightforward substitution cipher that replaces each plain text character with the obfuscated character obtained by shifting the plain text character a fixed number of positions in the alphabet. What is Cryptography? Before we introduce our first cryptographic algorithm, Caesar’s cipher, let’s first introduce cryptography … Read more

The Maximum Profit Algorithm in Python

This article presents an algorithmic problem with practical value for stock market analysis. For instance, suppose you are trading the cryptocurrency Ethereum. How much profit in dollars can you make by buying low and selling high based on historical data? Maximum Profit Basic Algorithm The max profit algorithm calculates the maximum profit you’d obtain by … Read more

How to Convert an Integer List to a String List in Python

The most Pythonic way to convert a list of integers ints to a list of strings is to use the one-liner strings = [str(x) for x in ints]. It iterates over all elements in the list ints using list comprehension and converts each list element x to a string using the str(x) constructor. This article … Read more

Python Beam Search Algorithm

You can check out the slide deck here to get a first intuition on how the algorithm works: Before we’ll dive into the algorithm and the Python implementation, let’s first skim over some related graph tutorials you may enjoy and that may help your understanding! Related Graph Tutorials This algorithm is part of our graph … Read more

Python Backtracking – A Helpful Guide with Video

You can check out the slides here (direct PDF link): Before we’ll dive into the algorithm and the Python implementation, let’s first skim over some related graph tutorials you may enjoy and that may help your understanding! Related Graph Tutorials This algorithm is part of our graph algorithm tutorials: Breadth-First Search (BFS) Algorithm in Python … Read more

Jump Search Algorithm in Python – A Helpful Guide with Video

As you watch the video, you can have a look at the slides as PDF: download slides in a new tab here. Before we’ll dive into the algorithm and the Python implementation, let’s first skim over some related graph tutorials you may enjoy and that may help your understanding! Related Graph Tutorials This algorithm is … Read more

How to Calculate the Edit Distance in Python?

Motivation Type “helo world” into your Google search bar and Google will ask you: “Did you mean: hello world”. How is this done? A simple method to detect these typos is the Levenshtein distance (also called edit distance). In fact, Google’s algorithm seems to use some variant of it. (source) By studying this article, you’ll … Read more

Iterative vs. Recursive Binary Search Algorithms in Python

In this article, you’ll learn about a basic algorithm, every computer scientist must know: the binary search algorithm. I have drawn the code from my NoStarch programming introductory book Python One-Liners: Applications Binary Search The algorithm has important practical applications in many basic data structures such as sets, trees, dictionaries, bags, bag trees, bag dictionaries, … Read more