Skip to content

Instantly share code, notes, and snippets.

@TrevorS
Created May 12, 2015 16:27
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 TrevorS/5e14454487dff30e67e3 to your computer and use it in GitHub Desktop.
Save TrevorS/5e14454487dff30e67e3 to your computer and use it in GitHub Desktop.
def find_best_order(array)
array.permutation.map { |p| [p, p.reduce { |a, e| a.to_s + e.to_s }] }.max_by { |e| e[1] }.first
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment