Skip to content

Instantly share code, notes, and snippets.

@hoxworth
Created April 12, 2009 00:14
Show Gist options
  • Save hoxworth/93792 to your computer and use it in GitHub Desktop.
Save hoxworth/93792 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
total = 0
curr = 0
while !STDIN.eof?
char = STDIN.read(1)[0]
if char < 48
total += curr
curr = 0
else
curr = curr*10 + (char - 48)
end
end
puts total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment