Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WordPair solution for the 2018 AP Computer Science Exam - https://compsci.rocks/wordpair-solution/
public int numMatches() {
int cnt = 0;
for (WordPair wp: allPairs)
if (wp.getFirst().equals(wp.getSecond())
cnt++;
return cnt;
}
public WordPairList(String[] words) {
allPairs = new ArrayList<>();
for (int i=0; i<words.length; i++)
for (x=i+1; x<words.length; x++)
allPairs.add(new WordPair(words[i], words[x]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.