Skip to content

Instantly share code, notes, and snippets.

View charmcitygavin's full-sized avatar

Gavin St. Ours charmcitygavin

View GitHub Profile

Keybase proof

I hereby claim:

  • I am charmcitygavin on github.
  • I am charmcitygavin (https://keybase.io/charmcitygavin) on keybase.
  • I have a public key ASDbXamsi-Jbjp8IqsUoHe-uyGwANMNd9g_TlpBp0_Tq7Qo

To claim this, I am signing this object:

@charmcitygavin
charmcitygavin / mode.rb
Last active December 10, 2015 15:28
This is as far as I've been able to get (so far) with the "Calculate the array mode" exercise in the DBC prep material. Am I on the right track? Am I making this too complicated on myself?
def mode(array)
# This sets up the hash, each new key defaulting to a value of 0
count = Hash.new(0)
# This iterates through the original array,
# increasing each number's hash value each time it appears in the array.
array.each do |number|