/* * Main.java * * Created on July 17, 2006, 2:51 AM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ import java.io.BufferedReader; import java.io.FileReader; /** * * @author Jayson */ public class AnagramSolver { // the string of jumbled letters String letters = "Al Kaline"; // String letters = "Tom Cruise"; // String letters = "Eric Clapton"; // an array counting characters int[] counts = getCounts(letters); /** * @param args the command line arguments */ public static void main(String[] args) throws Exception { // make a new instance of the class AnagramSolver m = new AnagramSolver(); // the dictionary of words Dictionary d = new Dictionary(); String[] words = d.getWords(); for (int i=0;i 0) { difference += diff; } else { difference -= diff; } } if (difference == 0) { return true; } return false; } public int[] getCounts(String s) { // make an array for tracking these counts int[] counts = new int['z'-'a'+1]; // loop over each char char[] chars = s.toLowerCase().replaceAll("[^a-z]", "").toCharArray(); for (int c=0;c