Here I’ll show you the basic concepts of the most famous word games…and how they are actually coded. Obviously, I’m NOT going to show you advanced algorithms or any proprietary information here. Just the basics…you go party on with this information with your own creativity.
There are numerous games out there based on this concept. You are given a set of letters, and you have to construct a word, the “correct” word. Very similar to Wheel of Fortune.
import random str = ['C','O','C','O','N','U','T','F','R','U','I','T'] random.shuffle(str); print("Shuffled:", str);
I have an array of characters (C/C++ guys get it!), or a list (Python guys get it!) of values. Now I can re-arrange the letters by using shuffle() function. The function comes from random module/library of Python. So, I use the import statement above. Within it, is the random.shuffle() method. So there we have it!
Everytime you run it, it’s going to be different 🙂 “Oh sir, one more thing….” (here)