Jumble Solver

Jumble Solver

<p> 110-15.1</p><p>COMP 110 Spring 2009</p><p>Jumble solver Due April 1, 2009 (no fooling)</p><p>Objectives Perform a search Manipulate strings</p><p>Start by looking at the Daily Jumble:</p><p>(http://www.shockwave.com/gamelanding/dailyjumble.jsp)</p><p>These puzzles consist of a series of words whose letters have been rearranged. Your job is to figure out the word. In these puzzles, each scrambled word has only one unscrambled solution. In general, however, a scrambled word may have many solutions. For example, "tsop" can be unscrambled into "stop", "tops", "spot", and "post"</p><p>We will solve this problem by brute force. That is, we will throw computing resources at the problem to solve it in a very straightforward way. </p><p>1. Read the dictionary</p><p>Go to the course web site and click on the link for the Program 5 dictionary. This should open a text window containing the dictionary. Save it as dictionary.js in your local directory. </p><p>Put the following into your html in the head</p><p><script type="text/javascript" src="dictionary.js"> </script></p><p>This will create an array called list with just over 25,000 strings. The strings contain both upper and lower case letters plus some other characters.</p><p>2. Convert all the strings in the dictionary to lower case. Hint: if s is a string variable, then s.toLowerCase() is the lower case version of s. All upper case letters are converted; all other characters are unaffected. Note that toLowerCase() doesn't change s; you have to do that with an assignment statement. Converting the dictionary to lower case takes about 4 lines of code (of which 2 are just brackets).</p><p>3. Use html to generate text boxes to enter up to four jumbled words and output area. Include simple instructions to the user, plus GO and RESET buttons. 110-15.2</p><p>4. The program: The user will enter jumbled words into the text boxes and press GO. All the un-jumbled words should appear in the output boxes. See the example. Your page need not look exactly like this one, but should contain the same basic parts. The text area at the bottom shows how many dictionary words were tested. Note that if you enter an un-jumbled word (for example, "stop" and "beat"), this word will appear in the output box along with possibly others. If there are no matches, display an appropriate message. This program will work for lots of jumbles words, but not all. The dictionary does not contain plurals or various verb forms, so some searches will be unsuccessful. Don't worry about this.</p><p>5. Etc. Hint on using eval. You can build a string containing a JavaScript instruction, then execute it with eval. For example, the following loop sets the value of four text areas (named t1, t2, t3, and t4, all in a form called f1) to blank.</p><p> for (var i=1; i<=4; i++) { eval("document.f1.t" + i + ".value=\"\";"); }</p><p>If you are having trouble understanding this statement, build the statement string first, then evaluate it. It might also help your understanding if you display the string.</p><p> for (var i=1; i<=4; i++) { var s = "document.f1.t"+ i+ ".value=\"\";"; alert(s); eval(s); }</p><p>It's easy to clear all fields using a reset button.</p><p><input type="reset" value="Reset"> 110-15.3</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    3 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us