Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Created May 6, 2016 22:36
Show Gist options
  • Save chuck0523/ec04eb13b98e01fe6b2f34d9b0a645dd to your computer and use it in GitHub Desktop.
Save chuck0523/ec04eb13b98e01fe6b2f34d9b0a645dd to your computer and use it in GitHub Desktop.
nums = [1, 2, 1, 4, 5, 5, 2, 3]
puts nums.max_by {|x| nums.count(x)}
max_size = nums.count(nums.max_by {|x| nums.count(x)})
puts nums.map { |x| x if nums.count(x) == max_size}.uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment