Skip to content

Instantly share code, notes, and snippets.

@bshlgrs
Created September 29, 2014 03:21
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 bshlgrs/70f85368cc4bf99ef682 to your computer and use it in GitHub Desktop.
Save bshlgrs/70f85368cc4bf99ef682 to your computer and use it in GitHub Desktop.
You're lifting weights in a gym, because that's what you're in to. This gym is
filled with a weird kind of bar bell bar which can only fit one weight on each
end of it.
Frustratingly, the weights might not be evenly matched. You want to do some
with as even a weight as possible. So you need to find the two weights
with the closest weight to each other.
Your input will be an array of weights, for example [2,10,15,25].
Your output should be an array containing the two weights which have the
closest weight to each other.
In that case, the output would be [10,15]. (Your right arm is stronger than
your left, so put the heavier weight on the right.) In case of ties, pick the
heaviest pair, because you're a gym bro like that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment