Tag Archives: scrabble

Scrabble Problem

If I give you scrabble tiles and a dictionary, determine the valid words
from your collection of tiles.

package joshho;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;

public class Runner {
	ScrabbleSet set ;
	private class ScrabbleSet {
		char[] chars;
		public ScrabbleSet(String[] orig){
			chars = new char[orig.length];
			for(int i=0;i chars.length) return false;
			int s=0;
			for(int i=0;i chars[j]) continue;
					if(find[i] == chars[j]){
					return false;
			return true;
	public void load(String y){
		set = new ScrabbleSet(y.split(" "));

	public static void main(String[] args) throws IOException {
		args = new String[]{"Scrabble\\data\\english4000.dic",
				"g w x b d u t z q m o i e p o"};
		FileReader fr =  new FileReader(args[0]);
		BufferedReader br = new BufferedReader(fr);

		Runner r = new Runner();
		String line;
		while((line = br.readLine()) != null) {
			System.out.print(line+" ");


There’s probably a better way to do this, I am interested
to see what other solutions there are.