Skip to content

Instantly share code, notes, and snippets.

@ben0x539
Created September 1, 2011 14:13
Show Gist options
  • Save ben0x539/1186249 to your computer and use it in GitHub Desktop.
Save ben0x539/1186249 to your computer and use it in GitHub Desktop.
import java.io.*;
import java.util.*;
public class Derp {
public static void main(String[] args) throws IOException {
if (args.length == 0)
return;
BufferedReader r = new BufferedReader(new FileReader(args[0]));
String line = r.readLine();
int n = Integer.parseInt(line);
LinkedList<LinkedList<Integer>> lists = new LinkedList<LinkedList<Integer>>();
for (int i = 0; i < n; ++i) {
String[] values = r.readLine().split(" ");
LinkedList<Integer> list = new LinkedList<Integer>();
for (int j = 0; j < n; ++j)
if (values[j].equals("1"))
list.add(j);
lists.add(list);
}
for (LinkedList<Integer> list : lists) {
for (int v : list)
System.out.print(v + " ");
System.out.println();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment