Home / Expert Answers / Computer Science / purpose-to-find-every-possible-permutation-of-letters-in-a-word-using-recursion-degree-of-difficul-pa402

(Solved): Purpose: To find every possible permutation of letters in a word using recursion Degree of Difficul ...




Purpose: To find every possible permutation of letters in a word using recursion
Degree of Difficulty: Tricky
In the game of
Purpose: To find every possible permutation of letters in a word using recursion Degree of Difficulty: Tricky In the game of Scrabble, players take turns placing lettered tiles onto a board to form words. The goal of the game is to score more points than the other players. Knowing all the possible words can be created from your letters is a significant advantage! For this question, we are going to write a recursive function to help us play Scrabble. A player has a set of tiles with letters but isn't sure what words can be made with them. So, our function is going to return a list containing every permutation of those letters. What is a permutation? It is simply the result of changing the order of a set of objects. In this case, we are going to take the letters in a word and mix them up into every combination possible. For example, the word bad has the following permutations: bad, bda, abd, adb, dba, dab and the word rip has the following permutations: rip, rpi, irp, ipr, pri, pir. Program Design Write a function permutations() which is recursive. It should take only one parameter, which should be a list of characters in that word. Your function should return a list of lists that contain all the permutations in a similar format as described above. Below is some helper code, to help you create such a list, and the expected return values. Note: The above code is an example showing how your code could run; permutations is the function that you should be creating! Include the code you used to test your function with 3 tiles (" ", "a", "t") and 4 tiles ('i', ' ', 'm', 't'). Making this solution recursive isn't an easy task, so here are some hints to help you: - You may need to use up to two loops inside of your recursive function! This is ok! However, your function still needs to effectively use recursion for full marks. - Only worry about permutations that include the same number of letters. (For example: all permutations of "cat" should have 3 letters.) - Slicing will be very important for this question! - Duplicate words will happen when there are several of the same letter in a word. Do not worry about removing duplicates!


We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe