Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- matrix = []
- ARGF.each do |line|
- ary = line.strip.split
- matrix << ary
- end
- matrix.transpose.each do |row|
- node_id = row.shift
- sum = row.map {|x| x.to_i}.inject(0) {|s, i| s + i}
- if sum == 1
- puts [node_id[/\d+/], row].flatten.join("\t")
- end
- end
Add Comment
Please, Sign In to add comment