How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Ingo U Your Own Question

Ingo U
Ingo U, Software Engineer
Category: Homework
Satisfied Customers: 755
Experience:  Over 25 years experience in software development. Expert in Microsoft .Net, C#, C++, VB, SQL
44076068
Type Your Homework Question Here...
Ingo U is online now
A new question is answered every 9 seconds

Unscramble permuted words by generating all permutations

Customer Question

Unscramble permuted words by generating all permutations of Jumble string and searching for word in Unix dictionary. It is due no later than Friday. It requires the programming language of Ruby on Rails, the output must be viewed in the command prompt, and the files should be saved as a rb file. There is a txt file for section three.  http://wikisend.com/download/842018/dict.txt. There is three parts to this HW.


http://wikisend.com/download/278714/hw.docx



1. Write a user defined function named to_array that converts a String object to an array like this:




        s = "dog" a = to_array(s)

        print a, "\n"









            • Output: ["d", "o", "g"]







2. Write a method called get_permulations that inputs an array of single characters (like ["d", "o", "g"]).  The  method should return an array of all permutations of the Jumble string. The permutations in the array should be in string format.




      a = ["d", "o", "g"] perms = get_permutations(a)




      print perms, "\n"





        Output: ["dog", "dgo", "odg", "ogd", "gdo", "god"]






3. Compare the words in the Unix dictionary to the permutation strings in the array. Print any matches that are found. Here is some that might help:





        Define to_array method (Item 1).

        Define get_permutations method (Item 2).






        # ***** main script.

        # ***** in a comment the Jumble strings you

        # ***** for testing. Include at least two test strings.






        Input Jumble string from keyboard. (Be sure to remove "\n" from end of input.)






        Obtain array of letters from Jumble string using to_array method (Item 1).






        Obtain array of permutations from array using get_permutations method (Item 2).






        Open Unix dictionary file to create file object fin.






        while more lines in dictionary file get line






          Get word from line of dictionary file.

          if word starts with a lower case letter

            for each permutation in array called perm

              if perm is equal to word

                 print word

                 exit script

              end

           end

          end



endClose file object fin.


 

 pseudocode section 3

 

Submitted: 1 year ago.
Category: Homework
Expert:  Ingo U replied 1 year ago.

HI, I will have a look at this. I got the hw doc and dict.txt, anything else I'll need?

What version of Ruby?

Customer: replied 1 year ago.
Ruby on Rails. 2.2. That's the latest version I've downloaded on my laptop.
Expert:  Ingo U replied 1 year ago.
Thanks - here are your files:
Parts 1#2:
https://www.dropbox.com/s/o4fj0k0144wp2i8/jumble_1_2.rb?dl=0
Part 3:
https://www.dropbox.com/s/biq25rolmrw1h5h/jumble_3.rb?dl=0
Make sure the dict.txt file is in the same directory.
Please let me know if you need anything else!
Regards,
Ingo
Customer: replied 1 year ago.

Is it possible to include test strings included in a comment and source code comments for what each particular section does? They don't have to be detailed just a brief sentence or comment.

Expert:  Ingo U replied 1 year ago.
OK, updated files are in the same place:
https://www.dropbox.com/s/o4fj0k0144wp2i8/jumble_1_2.rb?dl=0
https://www.dropbox.com/s/biq25rolmrw1h5h/jumble_3.rb?dl=0
Hope that helps!
Customer: replied 1 year ago.
Number 3 retrieves three words, can you possibly have it retrieve only one word. The classes in that document are a bit too advanced at this point in my class.
Expert:  Ingo U replied 1 year ago.
Do you mean only ask the user for 1 word to test, or only look for one match per test word in the dictionary?
Customer: replied 1 year ago.
To ask the user 1 word to tes and have it output one result.
Expert:  Ingo U replied 1 year ago.
THIS ANSWER IS LOCKED!

You need to spend $3 to view this post. Add Funds to your account and buy credits.
Customer: replied 1 year ago.
It's supposed to unscramble the words being entered. For example, if you type in tac it should print cat.
Expert:  Ingo U replied 1 year ago.
That's what I had before! Then you said one word to test and only one result. So now it only prints the first word found in the dictionary. well if you enter tac, it finds "act" before "cat".
So I took out the line "return" that makes it quit after finding a dictionary word. Now it prints "act" and "cat".
https://www.dropbox.com/s/biq25rolmrw1h5h/jumble_3.rb?dl=0
Expert:  Ingo U replied 1 year ago.
Hi,
just following up, were you able to use my solution?
Please feel free to post any additional questions, comments or concerns you may have regarding this issue.
If you're not yet satisfied with the result, please let me know what is missing.
I will do my best to make it right for you.
Otherwise, please don't forget to rate my service - I don't get paid for my work until your rating is received.
Regards,
Ingo U

Related Homework Questions