public class WordMatch {
    private String secret;
  
    public WordMatch (String word) {
      this.secret = word;
    }
  
    public int scoreGuess (String guess) {
      String word_copy = secret;
      int score = 0;
      for (int i = 0; i<secret.length(); i++) {
        if (word_copy.indexOf(guess) == 0) score++;
        word_copy = word_copy.substring(1, word_copy.length());
      }
      return score*guess.length()*guess.length();
    }
  
    public static void main (String[] args) {
      WordMatch game1 = new WordMatch("mississippi");
      System.out.println(game1.scoreGuess("i"));
      System.out.println(game1.scoreGuess("iss"));
      System.out.println(game1.scoreGuess("issipp"));
      System.out.println(game1.scoreGuess("mississippi"));
      System.out.println();
      WordMatch game2 = new WordMatch("aaaabb");
      System.out.println(game2.scoreGuess("a"));
      System.out.println(game2.scoreGuess("aa"));
      System.out.println(game2.scoreGuess("aaa"));
      System.out.println(game2.scoreGuess("aabb"));
      System.out.println(game2.scoreGuess("c"));
    }
  }
  
  WordMatch.main(null);
4
18
36
121

4
12
18
16
0
public class WordMatch {
    private String secret;
  
    public WordMatch (String word) {
      this.secret = word;
    }
  
    public int scoreGuess (String guess) {
      String word_copy = secret;
      int score = 0;
      for (int i = 0; i<secret.length(); i++) {
        if (word_copy.indexOf(guess) == 0) score++;
        word_copy = word_copy.substring(1, word_copy.length());
      }
      return score*guess.length()*guess.length();
    }
  
    public String findBetterGuess (String guess1, String guess2) {
      int score1 = scoreGuess(guess1);
      int score2 = scoreGuess(guess2);
      if (score1 > score2) return guess1;
      if (score1 < score2) return guess2;
      return (guess1.compareTo(guess2) > 0 ? guess1 : guess2);
    }
  
    public static void main (String[] args) {
      WordMatch game1 = new WordMatch("concatenation");
      System.out.println(game1.findBetterGuess("ten", "nation"));
      System.out.println(game1.findBetterGuess("con", "cat"));
    }
  }
  
  WordMatch.main(null);
nation
con