Skip to content

Instantly share code, notes, and snippets.

@chaoxu
Created September 6, 2010 14:56
Show Gist options
  • Save chaoxu/567133 to your computer and use it in GitHub Desktop.
Save chaoxu/567133 to your computer and use it in GitHub Desktop.
import java.util.*;
import java.math.*;
public class MultiWordIntersection{
public static int MultiIntersection(ArrayList<String> a, String sword){
int sum = 0;
SurfaceWord sw = new SurfaceWord(sword);
for(int i=0;i<a.size();i++){
WordVector p = new WordVector(sw.toNumber(a.get(i)));
for(int j=i+1;j<a.size();j++){
WordVector p1 = new WordVector(sw.toNumber(a.get(j)));
sum + = p.intersection(p1,sw);
}
sum-= p.selfIntersection(sw) * (a.size()-2);
}
return sum;
}
public static int MaxMultiIntegersection(ArrayList<ArrayList<String>> a, String sword){
int m = 0;
for(int i=0;i<a.size();i++){
m = Math.max(MultiIntersection(a.get(i), sword),m);
}
return m;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment