Skip to content
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

Between Two Sets #13

Open
theus opened this issue Feb 9, 2019 · 1 comment
Open

Between Two Sets #13

theus opened this issue Feb 9, 2019 · 1 comment

Comments

@theus
Copy link
Collaborator

theus commented Feb 9, 2019

https://www.hackerrank.com/challenges/between-two-sets/problem

@theus theus added the Algoritmo label Feb 9, 2019
@theus
Copy link
Collaborator Author

theus commented Feb 9, 2019

/*
 * Complete the getTotalX function below.
 */
function getTotalX(a, b) {
  const factors = []
  for (let n = a[0]; n <= b[0]; n++) {
    factors.push(n)
  }
  const checkIfIsFactorOfBElements = n => b.reduce((rest, number) => rest += number % n, 0) === 0
  const checkIfAIsAFactor = n => a.reduce((rest, number) => rest += n % number, 0) === 0 
  return factors.filter(checkIfIsFactorOfBElements).filter(checkIfAIsAFactor).length
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant