Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help making an unscrambling program
#11
KiZ I tried looking over it but really couldnt gather anything about it. Cananyone care to explain to me how to go around it. I got the concept Idea but cant implement it..
img]http://img213.imageshack.us/img213/6104/sig1jb.gif[/img]
Reply
#12
Quote:Andrew, we usually like to help people solve problems here, instead of just giving them the answer. It promotes learning. Especially when the person is doing homework.

I don't agree with that for these reasons....

1) Most people that are beginning to learn to program cannot do it without examples, It's akin to trying to learn French without someone showing how it's correctly done.

2) Giving someone the answer is not a bad thing. If they truly wish to learn they will pick the code apart. If they don't want to learn then they will be on their merry way.....

3) Promotion of learning start's first with the desire to learn. If they don't desire to learn, wether you give them the answer or explain how it's done won't make a difference. It will register with the portion of the brain that needs it, it will get used, then it will get tossed aside......

If you personally have trouble with coding something, is it better if someone explains it to you? Show's you how it's done? or both?


You can lead a horse to water, but you can't make him drink!


Edit:
I should say I don't agree with it but I'll still do it your way.
Reply
#13
Quote:KiZ I tried looking over it but really couldnt gather anything about it. Can anyone care to explain to me how to go around it. I got the concept Idea but cant implement it..

These are all taken from the FB help file...
  • MID returns a string containing the characters from the text string, starting at start, length characters long.

    MID[$](text, start[, length])

    INSTR function returns the position in the string subject for the first occurence of the string search.

    INSTR( [start,] subject, search )

    LEN will return the length of a variable or DataType. If the variable is a string, it will return the length in characters. Otherwise, it will return the number of bytes.

    LEN(Text$)



If our scrambled word is "ATC" and the word we wish to compare it to is "CAT" then
Our Dictword is "CAT" and our Srambword is "ATC"

First we check the length of both words to make sure they are the same length (If they are not then they are not the same word!)
LEN Command

then we do a simple loop based on the length of our DictWord "CAT"
FOR X = 1 to length of DictWord

We do a simple comparison...

If "C" from the DictWord is in the Scrambword then we remove the "C" from the DictWord.
We keep doing that until we have gone through as many letters as the length of the DictWord contains.

Use INSTR and MID

If "C" is in "ATC" then "CAT" = "AT"
If "A is in "ATC" then "AT" = "T"
If "T " is in "ATC" then "T" = ""

If our Dictword = "" (Blank) then you can build that word from the scrambled word.
Reply
#14
When it is a word list as opposed to two words, it becomes slightly different.

You can just:

Sort both lists according to size, along with indexes to remember what goes where.

Then:

Check all same-size words. But this takes a relatively long time, since you're checking ALL the same-size unscrambled words for each scrambled word.



*OR*...

1) Sort the letters in the words in both lists alphabetically.
2) Sort both lists, along with an index, to remember what word goes where.
3) Throw away duplicates in the non-scrambled word list.
4) Do a simple "=" check for each scrambled word in the list, comparing with unscrambled words. [If it =, then remember the indexes of both. Otherwise, go on to the next word.]

You'll want to use quicksort.

If this sounds complicated, it is. For a beginner, simple things can get complicated quickly...
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#15
I got it. Thanx for explaining now. When i edit it abit to my likings I will post the final result..
img]http://img213.imageshack.us/img213/6104/sig1jb.gif[/img]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)