Skip to content

Instantly share code, notes, and snippets.

@jgierer12
Last active May 4, 2017 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgierer12/9302f743a749c00cfdbb1ce939b6d7e6 to your computer and use it in GitHub Desktop.
Save jgierer12/9302f743a749c00cfdbb1ce939b6d7e6 to your computer and use it in GitHub Desktop.
export default arr => arr.some(x => arr.includes(-x));
import subsetSum from './subset-sum.js';
test('[1, 2, 3] -> false', () => {
expect(subsetSum([1, 2, 3])).toBeFalsy();
});
test('[-5, -3, -1, 2, 4, 6] -> false', () => {
expect(subsetSum([-5, -3, -1, 2, 4, 6])).toBeFalsy();
});
test('[] -> false', () => {
expect(subsetSum([])).toBeFalsy();
});
test('[-1, 1] -> true', () => {
expect(subsetSum([-1, 1])).toBeTruthy();
});
test('[-97364, -71561, -69336, 19675, 71561, 97863] -> true', () => {
expect(subsetSum([-97364, -71561, -69336, 19675, 71561, 97863])).toBeTruthy();
});
test('[-53974, -39140, -36561, -23935, -15680, 0] -> true', () => {
expect(subsetSum([-53974, -39140, -36561, -23935, -15680, 0])).toBeTruthy();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment