-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Added manhattan distance and euclidean distance for distance 2 points task #809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
de3e2f1
Added Hex to Binary conversion
ddhira123 1432037
Update Conversions/HexToBinary.js
ddhira123 6efa3db
Update Conversions/HexToBinary.js
ddhira123 3123322
Update Conversions/HexToBinary.js
ddhira123 b70af8d
Update Conversions/HexToBinary.js
ddhira123 b4814b1
Merge branch 'master' into master
ddhira123 45d14b7
Fix errors
ddhira123 5dbc20f
fix: typo
raklaptudirm 26a4b28
Merge branch 'master' of https://github.com/TheAlgorithms/Javascript
ddhira123 8ede06c
Added Manhattan Distance Algorithm
ddhira123 4ddef0f
Merge branch 'master' of https://github.com/ddhira123/Javascript
ddhira123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,43 @@ | ||
import * as coordinate from '../Coordinate' | ||
|
||
describe('Testing distance2points calculations', () => { | ||
describe('Testing euclideanDistance calculations', () => { | ||
it('Should give a numeric output (distance between 2 points) with 4 numeric arguments', () => { | ||
const distance2points = coordinate.distance2points(2, 2, -10, -7) | ||
expect(distance2points).toBe(15) | ||
const euclideanDistance = coordinate.euclideanDistance(2, 2, -10, -7) | ||
expect(euclideanDistance).toBe(15) | ||
}) | ||
it('Should not give any output given non-numeric argument', () => { | ||
const distance2points = coordinate.distance2points('ABC', '123', '', '###') | ||
expect(distance2points).toBeNaN() | ||
const euclideanDistance = coordinate.euclideanDistance('ABC', '123', '', '###') | ||
expect(euclideanDistance).toBeNaN() | ||
}) | ||
it('Should not give any output given any number of numeric arguments less than 4', () => { | ||
const distance2points3arg = coordinate.distance2points(2, 2, -10) | ||
const distance2points2arg = coordinate.distance2points(2, 2) | ||
const distance2points1arg = coordinate.distance2points(2) | ||
const distance2points0arg = coordinate.distance2points() | ||
expect(distance2points3arg).toBeNaN() | ||
expect(distance2points2arg).toBeNaN() | ||
expect(distance2points1arg).toBeNaN() | ||
expect(distance2points0arg).toBeNaN() | ||
const euclideanDistance3arg = coordinate.euclideanDistance(2, 2, -10) | ||
const euclideanDistance2arg = coordinate.euclideanDistance(2, 2) | ||
const euclideanDistance1arg = coordinate.euclideanDistance(2) | ||
const euclideanDistance0arg = coordinate.euclideanDistance() | ||
expect(euclideanDistance3arg).toBeNaN() | ||
expect(euclideanDistance2arg).toBeNaN() | ||
expect(euclideanDistance1arg).toBeNaN() | ||
expect(euclideanDistance0arg).toBeNaN() | ||
}) | ||
}) | ||
|
||
describe('Testing manhattanDistance calculations', () => { | ||
it('Should give a numeric output (distance between 2 points) with 4 numeric arguments', () => { | ||
const manhattanDistance = coordinate.manhattanDistance(2, 2, -10, -7) | ||
expect(manhattanDistance).toBe(21) | ||
}) | ||
it('Should not give any output given non-numeric argument', () => { | ||
const manhattanDistance = coordinate.manhattanDistance('ABC', '123', '', '###') | ||
expect(manhattanDistance).toBeNaN() | ||
}) | ||
it('Should not give any output given any number of numeric arguments less than 4', () => { | ||
const manhattanDistance3arg = coordinate.manhattanDistance(2, 2, -10) | ||
const manhattanDistance2arg = coordinate.manhattanDistance(2, 2) | ||
const manhattanDistance1arg = coordinate.manhattanDistance(2) | ||
const manhattanDistance0arg = coordinate.manhattanDistance() | ||
expect(manhattanDistance3arg).toBeNaN() | ||
expect(manhattanDistance2arg).toBeNaN() | ||
expect(manhattanDistance1arg).toBeNaN() | ||
expect(manhattanDistance0arg).toBeNaN() | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.