HTW Berlin Medieninformatik

HTW Berlin
Fachbereich 4
Internationaler Bachelor Studiengang
Internationale Medieninformatik (Bachelor)
Info 2: Informatik II
Summer Term 2023


Exercise 13: Scrabble Cheater Deluxe

Finger exercises :
 

  1. What was a permutation? How can you generate all permutations of the characters in a String? What if some of the letters are the same.
  2. Given a selection of n pizza toppings - how can you generate a list of all of the different k-toppings where k<n? Hint: Look at the binomial coefficient. Write a method that takes a String of n characters and returns an array of k-character Strings that are all characters in the original string.
In class:
  1. Choose one of your solutions to Exercise 11 from last week (or borrow a working one from someone else. Remember to give them credit!).
  2. If you didn't do this last week, write a method bool isPermutation (String a, String b) {...} that determines if a and b are permutations. Use this in your output from the cheater so that only permutations of the input string are printed out, and not all of the collisions.
  3. Adapt your main method to generate a random selection of seven letters to start the cheater with.
  4. Make a class that upon instantiation with a given String of characters, determines all of the Strings that are substrings in the sense that they only contain letters from the given String, with multiples only up to the number of multiples available. The order of the letters is irrelevant, so this is a bag. For example with 4 letters "JAVA" this would be {"AAJV", "AJV", "AAJ", "AAV", "AA", "AJ", "AV", "JV"}. Don't worry about single letters. Your finger exercise should come in handy here.
  5. Now set up the Scrabble Cheater DeLuxe: read in 7 letters, split them into collections of 7-, then 6-, then 5-, ... words contained in the input bag of letters. Look up each word in each collection in the corresponding dictionary. If you find something, output it.
  6. (For the bored) Generate your random selection of characters depending on the Scrabble distribution for English
  7. (For the bored) Collect up all the words which are only permutations of the looked up word, and sort them all, irrespective of length, alphabetically, before outputting them.
  8. (For the really bored) Check out http://www.morewords.com and see that you can use wild cards such as "-" for matching any one character and "*" for matching any string. Can you replicate this behavior (even if it is much slower than morewords)?  


Copyright Prof. Dr. Debora Weber-Wulff
Questions or comments: <weberwu@htw-berlin.de>
Some rights reserved. CC-BY-NC-SA - Copyright and Warranty