Skip to content

Instantly share code, notes, and snippets.

@martin2110
Created August 27, 2014 03:08
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 martin2110/24a45a3278258e8e8a4c to your computer and use it in GitHub Desktop.
Save martin2110/24a45a3278258e8e8a4c to your computer and use it in GitHub Desktop.
arr = [1,2,3,4,5,5,6,7,7,7]
track = Hash.new
arr.each_with_index do | num, index |
unless track[num]
track[num] = Array.new
end
track[num].push(index)
end
track.each { |key, value|
if value.count == 1
puts "number: #{key} at index #{value}"
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment