Skip to content

Instantly share code, notes, and snippets.

View MarkJRigdon's full-sized avatar

Mark MarkJRigdon

  • Cape Girardeau, MO
View GitHub Profile
def sum(array)
return array.inject(:+)
end
def max_num_char_str(string)
split_string = string.split("")
count_hash = Hash.new(0)
split_string.each do |c|
count_hash[c] += 1 unless c == " "
end
count_hash.max_by { | c, n | n }.join
end
puts max_num_char_str("lots of sss to show")
def reverse_string(string)
split_string = string.split("")
split_string.reduce([]) { |a, b| a.unshift(b) }.join
#reversed = []
#string.size.times { reversed << split_string.pop}
#reversed.join
end
puts reverse_string("codelabs")