Day 7 of 100
Source: Dev.to
Day 7 of 100: Writing Algorithms
Choosing a Project
I started the day by brainstorming simple game ideas and translating them into algorithms. After sketching a few concepts on paper and refining them in draw.io, I settled on creating a Hangman game and wrote the algorithm before beginning the actual build.
Preparing the Word List
The first step was to compile a list of possible words. This turned out to take more time than writing the program itself, but it gave the game a solid foundation.
Core Implementation
- Underscore Replacement – Used
forloops to replace each letter in the chosen word with an underscore. - User Guess Handling – Created a
guessvariable to capture the player’s input.- If the guessed letter exists in the word, the corresponding underscore(s) are replaced with that letter.
- If the guessed letter is not in the word, the player loses a life.
- If the letter has already been guessed, the player is informed that it was previously tried.
- Game Loop – Wrapped the entire logic in a
whileloop that continues until:- The user correctly guesses the whole word, or
- The user runs out of lives.
Reflection
Overall, building the Hangman game was a fun and educational mini‑project that reinforced my understanding of loops, conditionals, and user input handling.