app/src/main/java/com/google/engedu/anagrams/AnagramDictionary.java
public String pickGoodStarterWord() {
        String s = new String();
        ArrayList<String> aList = new ArrayList<String>();
        int r = random.nextInt(wordList.size());
        //source: http://stackoverflow.com/questions/18725428/going-back-to-the-first-index-after-reaching-the-last-one-in-an-array
        for(int i = r, j = 0; j < wordList.size()-1; i++, j++){ //start at random position
            i = i % (wordList.size()-1); //loop back to beginning of array if necessary
            String getWord = sortLetters(wordList.get(i));
            if(lettersToWord.containsKey(getWord)){
                if(lettersToWord.get(getWord).size() >= MIN_NUM_ANAGRAMS) {
                    aList.addAll(lettersToWord.get(getWord));
                    if (aList.size() >= MIN_NUM_ANAGRAMS) {
                        s = wordList.get(i);
                        break;
                    }
                }
            }
        }
        return s;
    }
//choosing a word in arrayList with at least 5 anagrams
choosing a word in arrayList with at least 5 anagrams
choosing a word in arrayList with at least 5 anagrams
public String pickGoodStarterWord() {
        String s = new String();
        ArrayList<String> aList = new ArrayList<String>();
        int r = random.nextInt(wordList.size());
        for(int i = r, j = 0; j < wordList.size()-1; i++, j++){ 
            i = i % (wordList.size()-1); 
            String getWord = sortLetters(wordList.get(i));
            if(lettersToWord.containsKey(getWord)){
                if(lettersToWord.get(getWord).size() >= MIN_NUM_ANAGRAMS) {
                    aList.addAll(lettersToWord.get(getWord));
                    if (aList.size() >= MIN_NUM_ANAGRAMS) {
                        s = wordList.get(i);
                        break;
                    }
                }
            }
        }
        return s;
    }
public String pickGoodStarterWord ( ) { String s = new String ( ) ; ArrayList < String > aList = new ArrayList < String > ( ) ; int r = random . nextInt ( wordList . size ( ) ) ; for ( int i = r , j = 0 ; j < wordList . size ( ) - 1 ; i ++ , j ++ ) { i = i % ( wordList . size ( ) - 1 ) ; String getWord = sortLetters ( wordList . get ( i ) ) ; if ( lettersToWord . containsKey ( getWord ) ) { if ( lettersToWord . get ( getWord ) . size ( ) >= MIN_NUM_ANAGRAMS ) { aList . addAll ( lettersToWord . get ( getWord ) ) ; if ( aList . size ( ) >= MIN_NUM_ANAGRAMS ) { s = wordList . get ( i ) ; break ; } } } } return s ; }
choosing a word in arrayList with at least 5 anagrams
choosing a word in arrayList with at least 5 anagrams
//source: http://stackoverflow.com/questions/18725428/going-back-to-the-first-index-after-reaching-the-last-one-in-an-array //start at random position //loop back to beginning of array if necessary