Cracking the Secret Codes
Every year, I like to program cards for my family for special events, including:
- Birthdays
- Father's Day
- Mother's Day
- etc.
I don't normally post the cards I program, but I was really proud of Mom's code breaking challenge this year, so I wanted to go ahead and post the source code. I hope that you can also enjoy playing it! I've removed any personal family references from the code.
To compile the code, you need to have the GNU Readline Library installed on your system.
Ubuntu:
sudo apt install libreadline-dev
Fedora:
sudo yum install readline-devel
Windows:
There is also a Windows version, but it is a bit trickier to install and configure the shared library and header files.
You will also need a C++11
compiler and GNU Make.
To compile the code, simply run:
make
To rebuild the code, type:
make clean
make
This will produce MothersDay2020.out
for the executable.
./MothersDay2020.out <WordsFile>
The game requires a text file of English words to use with the code algorithms. The program loads all words that are at least 10 letters long and only contain lowercase letters (so no capital letters, dashes, commas, apostrophies, etc.). The text file I used is words.txt from the GitHub repository english-words. However, you can use other dictionaries as well.
All Commands:
- help = Help screen
- word = Reshow the scrambled word
- hint = Ask a hint for the problem
- new = Pick a new word and reset the problem
- quit = Exit the program
- <solution> = Solve the problem
Undocumented Commands:
- cheat = Used for debugging to show the solution
Level 1
First letter and last letter swappedLevel 2
Word ReversedLevel 3
Shifted right 1 letterLevel 4
Every letter becomes next letter (a->b, b->c, etc.)Level 5
Shifted left 1 letter and reversedLevel 6
Vowels converted to symbolsLevel 7
First half and second half swappedLevel 8
Interweaved letters, indicated by capital lettersLevel 9
Every letter increased by a random amount (a->a+n)Level 10
Random letter subsitutionThe source code uses ClangFormat and Clang-Tidy to format the code and maintain a consistant style. You can either run these programs manually or install a plugin into your favorite code editor.