Skip to content

Instantly share code, notes, and snippets.

@sdmx
Created September 29, 2014 23:32
Show Gist options
  • Save sdmx/a8cecfeeced1f99b464a to your computer and use it in GitHub Desktop.
Save sdmx/a8cecfeeced1f99b464a to your computer and use it in GitHub Desktop.
ruby snipper for calc task
def Add(numbers)
delim=numbers.scan(/^..(.)$/m)
adds=numbers.split(/\n/)
array=adds[1].split(/#{delim}/)
#puts delim
puts array
sum=array.compact.map{ |s| s.to_i}
sum=sum.inject(:+).to_i
puts sum
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment