Asked • 06/19/19

All possible words?

I want to create all possible 5 letter words using a-z.Please suggest any good and fast algorithms. I have tried creating one and it looks something like this... byte[] allchar=new byte[] {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; int lengthOfAllChar=allchar.length; System.out.println(lengthOfAllChar); for (int i = 0; i < lengthOfAllChar; i++){ for(int j = 0; i < lengthOfAllChar; j++){ StringBuffer finalWordBuffer = new StringBuffer(); finalWordBuffer.append((char)allchar[i]); finalWordBuffer.append((char)allchar[j]); } }

Inactive Tutor

Also I am using capital letters.... if you want lowercase letters, then per the ASCII table, your for loops start at a=97 and end at z=122
Report

06/25/19

1 Expert Answer

By:

Inactive Tutor answered • 06/25/19

Tutor
New to Wyzant

Inactive Tutor

Probably would be best on another thread, or redirect the output to file. As stated you have over 11 million character strings to store
Report

06/25/19

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.