def find_missing_letter(arr)
arr.each_cons(2) do |letter, next_letter|
return letter.next if letter.next != next_letter
end
end
def find_missing_letter(arr)
((arr.first..arr.last).to_a - arr).first
end
Test.assert_equals(find_missing_letter(["a","b","c","d","f"]), "e")
def revrot(str, sz)
return "" if sz <= 0 or sz.nil? or sz > str.length
return_str = []
chunks = str.scan(/.{#{sz}}/)
chunks.each do |chunk|
cubed_digits = chunk.split('').map(&:to_i).map { |digit| digit*digit*digit }
chunk = cubed_digits.reduce(:+).even? ? chunk.reverse : chunk[1..-1] + chunk[0]
return_str << chunk
end
return_str.join
end
def revrot(str, sz)
return '' if sz <= 0
chunks = str.scan(/.{#{sz}}/)
chunks.map do |chunk|
digits = chunk.chars
sum = digits.map {|x| x.to_i ** 3 }.inject(:+)
sum.even? ? digits.reverse : digits.rotate
end.join
end
testing(revrot("733049910872815764", 5), "330479108928157")