mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
feat: add strings/ngram algorithm (#6074)
* feat: added ngram algorithm * fix(test): use `math.isclose` to match floating point numbers approximately Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
This commit is contained in:
@ -12,8 +12,12 @@ def polar_force(
|
||||
"""
|
||||
Resolves force along rectangular components.
|
||||
(force, angle) => (force_x, force_y)
|
||||
>>> polar_force(10, 45)
|
||||
[7.071067811865477, 7.0710678118654755]
|
||||
>>> import math
|
||||
>>> force = polar_force(10, 45)
|
||||
>>> math.isclose(force[0], 7.071067811865477)
|
||||
True
|
||||
>>> math.isclose(force[1], 7.0710678118654755)
|
||||
True
|
||||
>>> polar_force(10, 3.14, radian_mode=True)
|
||||
[-9.999987317275396, 0.01592652916486828]
|
||||
"""
|
||||
@ -50,7 +54,11 @@ def in_static_equilibrium(
|
||||
if __name__ == "__main__":
|
||||
# Test to check if it works
|
||||
forces = array(
|
||||
[polar_force(718.4, 180 - 30), polar_force(879.54, 45), polar_force(100, -90)]
|
||||
[
|
||||
polar_force(718.4, 180 - 30),
|
||||
polar_force(879.54, 45),
|
||||
polar_force(100, -90),
|
||||
]
|
||||
)
|
||||
|
||||
location = array([[0, 0], [0, 0], [0, 0]])
|
||||
|
Reference in New Issue
Block a user