Skip to content

Instantly share code, notes, and snippets.

@0x1eef

0x1eef/tests.rb Secret

Created December 7, 2022 23:08
Show Gist options
  • Save 0x1eef/5eadee0f1015f71c7aa880309abade59 to your computer and use it in GitHub Desktop.
Save 0x1eef/5eadee0f1015f71c7aa880309abade59 to your computer and use it in GitHub Desktop.
tests = {
[1,1,1,1,0] => 0,
[ 1, 1, 1, 2, 1, 1 ] => 2,
[ 0, 0, 0.55, 0, 0 ] => 0.55
}
tests.each do |arr, expected|
h = Hash.new(0)
arr.each { |el| h[el] += 1 }
p h.min_by { _2 }.first
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment