Last active
May 18, 2018 12:54
-
-
Save ClassCubeGists/c08fd685d9a5da18ab4a6631eb765cbc to your computer and use it in GitHub Desktop.
WordPairList Solution - AP 2018 FRQ - https://clsc.be/26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int numMatches() { | |
int cnt = 0; | |
for (WordPair wp: allPairs) | |
if (wp.getFirst().equals(wp.getSecond()) | |
cnt++; | |
return cnt; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment