Skip to content

Instantly share code, notes, and snippets.

@bchase
Created June 27, 2014 02:14
Show Gist options
  • Save bchase/ee8ce87256085997ac83 to your computer and use it in GitHub Desktop.
Save bchase/ee8ce87256085997ac83 to your computer and use it in GitHub Desktop.
text = (1..10_000).inject('') do |str, num|
str << "#{num} ".gsub(/0/,' ')
end
total = text.split(' ').map(&:to_i).inject(:+)
puts total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment