Skip to content

Instantly share code, notes, and snippets.

View pmashchak's full-sized avatar

Pavlo Mashchak pmashchak

  • Atkins & Pearce
  • Orlando, FL
View GitHub Profile
@pmashchak
pmashchak / occure.rb
Created April 2, 2014 18:42
Find occurences in string
a = 'Baloon . || woo,,ooddreeeed'
occurences = Hash.new(0)
array = a.gsub(/\W+/, '').split('')
array.each_with_index do |el, idx|
break if array.size == idx + 1
if el == array[idx + 1] && el != array[idx - 1]
occurences[el] += 1
end
end