Guest User

Untitled

a guest
Mar 16th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. matrix = []
  4.  
  5. ARGF.each do |line|
  6. ary = line.strip.split
  7. matrix << ary
  8. end
  9.  
  10. matrix.transpose.each do |row|
  11. node_id = row.shift
  12. sum = row.map {|x| x.to_i}.inject(0) {|s, i| s + i}
  13. if sum == 1
  14. puts [node_id[/\d+/], row].flatten.join("\t")
  15. end
  16. end
Add Comment
Please, Sign In to add comment