mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Fix some typos (#6113)
* Fix some typos. * Update volume.py Co-authored-by: John Law <johnlaw.po@gmail.com>
This commit is contained in:
parent
a7e4b2326a
commit
e1ec661d4e
|
@ -9,7 +9,7 @@ class ShuffledShiftCipher:
|
||||||
This algorithm uses the Caesar Cipher algorithm but removes the option to
|
This algorithm uses the Caesar Cipher algorithm but removes the option to
|
||||||
use brute force to decrypt the message.
|
use brute force to decrypt the message.
|
||||||
|
|
||||||
The passcode is a a random password from the selection buffer of
|
The passcode is a random password from the selection buffer of
|
||||||
1. uppercase letters of the English alphabet
|
1. uppercase letters of the English alphabet
|
||||||
2. lowercase letters of the English alphabet
|
2. lowercase letters of the English alphabet
|
||||||
3. digits from 0 to 9
|
3. digits from 0 to 9
|
||||||
|
|
|
@ -10,7 +10,7 @@ such as: (5 + ((4 * 2) * (2 + 3)))
|
||||||
|
|
||||||
THESE ARE THE ALGORITHM'S RULES:
|
THESE ARE THE ALGORITHM'S RULES:
|
||||||
RULE 1: Scan the expression from left to right. When an operand is encountered,
|
RULE 1: Scan the expression from left to right. When an operand is encountered,
|
||||||
push it onto the the operand stack.
|
push it onto the operand stack.
|
||||||
|
|
||||||
RULE 2: When an operator is encountered in the expression,
|
RULE 2: When an operator is encountered in the expression,
|
||||||
push it onto the operator stack.
|
push it onto the operator stack.
|
||||||
|
|
|
@ -11,7 +11,7 @@ algorithm which runs in nlogn and the brute-force n^2 algorithm.
|
||||||
|
|
||||||
def count_inversions_bf(arr):
|
def count_inversions_bf(arr):
|
||||||
"""
|
"""
|
||||||
Counts the number of inversions using a a naive brute-force algorithm
|
Counts the number of inversions using a naive brute-force algorithm
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
arr: arr: array-like, the list containing the items for which the number
|
arr: arr: array-like, the list containing the items for which the number
|
||||||
|
|
|
@ -38,8 +38,8 @@ def vol_spheres_intersect(
|
||||||
Calculate the volume of the intersection of two spheres.
|
Calculate the volume of the intersection of two spheres.
|
||||||
|
|
||||||
The intersection is composed by two spherical caps and therefore its volume is the
|
The intersection is composed by two spherical caps and therefore its volume is the
|
||||||
sum of the volumes of the spherical caps. First it calculates the heights (h1, h2)
|
sum of the volumes of the spherical caps. First, it calculates the heights (h1, h2)
|
||||||
of the the spherical caps, then the two volumes and it returns the sum.
|
of the spherical caps, then the two volumes and it returns the sum.
|
||||||
The height formulas are
|
The height formulas are
|
||||||
h1 = (radius_1 - radius_2 + centers_distance)
|
h1 = (radius_1 - radius_2 + centers_distance)
|
||||||
* (radius_1 + radius_2 - centers_distance)
|
* (radius_1 + radius_2 - centers_distance)
|
||||||
|
|
|
@ -88,7 +88,7 @@ iv) a1 is corresponding equal character of a5 in palindrome with center a3 (reme
|
||||||
now for a5 we will calculate the length of palindromic substring with center as a5 but
|
now for a5 we will calculate the length of palindromic substring with center as a5 but
|
||||||
can we use previously calculated information in some way?
|
can we use previously calculated information in some way?
|
||||||
Yes, look the above string we know that a5 is inside the palindrome with center a3 and
|
Yes, look the above string we know that a5 is inside the palindrome with center a3 and
|
||||||
previously we have have calculated that
|
previously we have calculated that
|
||||||
a0==a2 (palindrome of center a1)
|
a0==a2 (palindrome of center a1)
|
||||||
a2==a4 (palindrome of center a3)
|
a2==a4 (palindrome of center a3)
|
||||||
a0==a6 (palindrome of center a3)
|
a0==a6 (palindrome of center a3)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user