Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Innova solutions count host number from file and write to other file
filename = gets.strip
res = [] do |line|
res << line.split(' ').first
res_hash =
res.each { |i| res_hash[i] += 1 }
text_array = { |res| res.join(' ') }
out_filename = 'records_'+filename, 'w+') do |file|
text_array.each { |elem| file.puts(elem) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment