File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Java program to solve scramles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java program to solve scramles" Watch "Java program to solve scramles" New topic
Author

Java program to solve scramles

Asif Syed
Greenhorn

Joined: Apr 07, 2012
Posts: 4

Need help to associate a java netbeans ide program with any kinda dictionary to check out if any word found out by scramle exists or not..

Regards AsifSyed([email edited out. UseTheForumNotEmail])
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Welcome to the Ranch!

Asif Syed wrote:Need help to associate a java netbeans ide programp


It doesn't matter what IDE you use. You can write the same program with any IDE, or with a text editor. And in fact, as a beginner, it's better if you don't use an IDE just yet.

with any kinda dictionary to check out if any word found out by scramle exists or not..


Your first step is to figure out how you'd do it "by hand." If you don't understand and cannot express simply and in details the steps for doing in without Java, you'll have an awfully hard time writing it in Java.

You'll also need to ShowSomeEffort(⇐click) and TellTheDetails(⇐click) about what you tried and what specific trouble you're having, in order for people here to be able to help you.

Asif Syed
Greenhorn

Joined: Apr 07, 2012
Posts: 4

Sir,
I am quiet familiar with java, and am planning to give my SCJP exam this month. I thing i cant figure out is how to associate my program with a dictionary.

My logic goes this way :
1) Find out all the words that can be made with the given scramble by combinations.(<== Have completed this one)
2) Check out the words that exists i the dictionary with a meaning and hence display it.(<== am stuck in this step.!)

Please help me out.!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Asif Syed wrote:2) Check out the words that exists i the dictionary with a meaning and hence display it.(<== am stuck in this step.!)


It's hard to help without knowing how you have implemented your dictionary. So why don't you start by explaining that?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11256
    
  16

Asif Syed wrote:
2) Check out the words that exists i the dictionary with a meaning and hence display it.(<== am stuck in this step.!)

I see at least three pieces here:

1) check to see if the word exists in the dictionary
2) if it does, get the meaning
3) Display it

Which of these three are you stuck on? What have you tried?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

What kind of dictionary do you want to use? Some sort of offline dictionary? An online dictionary, perhaps using a webservice?

(In the latter case keep in mind you could generate so many requests to make the service provider very unhappy with you. Number of possible permutations grows very quickly with the number of letters. For a word composed of 8 unique letters this would be over 40 thousand requests.)
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Asif Syed wrote:Sir,
I am quiet familiar with java, and am planning to give my SCJP exam this month.


I'm not questioning your Java knowledge (though I've never seen any actual correlation between SCJP and Java knowledge).

I'm simply asking you to put a bit more effort into your research, your development process, and the question you post here.

I thing i cant figure out is how to associate my program with a dictionary.

My logic goes this way :
1) Find out all the words that can be made with the given scramble by combinations.(<== Have completed this one)
2) Check out the words that exists i the dictionary with a meaning and hence display it.(<== am stuck in this step.!)

Please help me out.!


What form does your dictionary take? Are you using an existing one, with its own API? Are you creating your own?

In the simplest case, you would simply have a Set or a sorted List of all the words, and it would be a simple matter of calling the contains() method, or else you'd have obtained some API and you would consult that API's docs to find out how to test for the existence of a word. However, since you're quite familiar with Java, you clearly already know that. Perhaps you could provide a little more detail about your approach and what in particular you're having trouble with?
Asif Syed
Greenhorn

Joined: Apr 07, 2012
Posts: 4

Nopes, I am done only with the first step. **@fred rosenberger

Cant think of what to do about the second.

This means, I cant understand how i can make my program find out the correct unscrambled word with the help of a dictionary!

Yea, that would generate a lot of words but amongst them i need to find out the meaningful one, that is why i need the help of the dictionary. **@fred rosenberger

Yea, I know, using a online dictionary, the service provider can be very unhappy with me,but in that case, I need to come over with an alternative, which at present I dont know(If you tell me, i can use that). **@martin vajsar

My main motive is to unscramble the scrambled words. **@paul clapham
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

It's still impossible to tell which of these is your problem:

(1) You don't know what data structure to use to implement a dictionary

(2) You don't know where to get the list of words to put into that data structure

Or is it both of them? Or something else?
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2343
    
  28

Well, the simplest solution is that you can just store all your dictionary words in a map. Since, you already figured out how to get permutations of all the words that can be made using the provided letters, you just need to look up whether the permutation exists in the map

Not the best solution, but will work for small letter sets. Remember that the performance of this solution is O(n!) where n is the number of letters that you have. Or in other words, very very bad.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java program to solve scramles