<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: CodeWizardX1</title>
    <description>The latest articles on DEV Community by CodeWizardX1 (@codewizardx1).</description>
    <link>https://dev.to/codewizardx1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2122208%2F100ea593-7256-48bc-bfdf-5138df039bf4.png</url>
      <title>DEV Community: CodeWizardX1</title>
      <link>https://dev.to/codewizardx1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codewizardx1"/>
    <language>en</language>
    <item>
      <title>Building a Simple CPU Simulator in Python</title>
      <dc:creator>CodeWizardX1</dc:creator>
      <pubDate>Fri, 14 Feb 2025 05:09:59 +0000</pubDate>
      <link>https://dev.to/codewizardx1/building-a-simple-cpu-simulator-in-python-448d</link>
      <guid>https://dev.to/codewizardx1/building-a-simple-cpu-simulator-in-python-448d</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;I created this project for my CS104 course on Codecademy. As part of learning computer architecture, I wanted to understand, on a hands‐on level, how a CPU fetches, decodes, and executes instructions. This simulator demonstrates the fundamentals of CPU registers, memory, and arithmetic instructions in a neat little package—all in Python.  &lt;/p&gt;




&lt;h3&gt;
  
  
  About the Python Code
&lt;/h3&gt;

&lt;p&gt;In this simulator, each instruction (like &lt;code&gt;ADD&lt;/code&gt;, &lt;code&gt;SUB&lt;/code&gt;, &lt;code&gt;MUL&lt;/code&gt;, &lt;code&gt;DIV&lt;/code&gt;) is stored in a simple text‐based format (&lt;code&gt;"ADD,R1,R2,R3"&lt;/code&gt;) inside a memory list. The CPU class then performs the core operations:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Store Values in Registers&lt;/strong&gt;: It can store integer data in registers before running an instruction.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fetch&lt;/strong&gt;: It reads the next instruction from memory, incrementing a &lt;code&gt;program_counter&lt;/code&gt; as it goes.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decode&lt;/strong&gt;: It splits the instruction string into an opcode (e.g., &lt;code&gt;ADD&lt;/code&gt;) and operand registers (like &lt;code&gt;R1, R2, R3&lt;/code&gt;) to understand which registers to reference.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Execute&lt;/strong&gt;: It carries out the arithmetic or logical instruction, modifying the registers as needed.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For example, if the code sees &lt;code&gt;ADD,R5,R1,R2&lt;/code&gt;, it takes the values in registers &lt;code&gt;R1&lt;/code&gt; and &lt;code&gt;R2&lt;/code&gt;, sums them, and stores the result in &lt;code&gt;R5&lt;/code&gt;. It’s a streamlined way to get a feel for how real CPUs handle instructions step by step.&lt;/p&gt;

&lt;p&gt;Check out my &lt;strong&gt;GitHub repo&lt;/strong&gt; for the full code and examples: &lt;a href="https://github.com/CodeWizardX1/cpu_simulator" rel="noopener noreferrer"&gt;GitHub: CodeWizardX1/cpu_simulator&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Building this Python CPU simulator gave me a much better appreciation for how processors orchestrate memory, registers, and instructions. It’s a toy example, but the main concepts—fetch, decode, execute—are the same building blocks used by real hardware. Feel free to explore the repository, try adding new instructions, or extend its capabilities.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Building MooVeeMatch: A Mood-Based Movie Recommendation Program 🎥✨</title>
      <dc:creator>CodeWizardX1</dc:creator>
      <pubDate>Sat, 21 Dec 2024 21:56:49 +0000</pubDate>
      <link>https://dev.to/codewizardx1/building-mooveematch-a-mood-based-movie-recommendation-program-598c</link>
      <guid>https://dev.to/codewizardx1/building-mooveematch-a-mood-based-movie-recommendation-program-598c</guid>
      <description>&lt;h2&gt;
  
  
  Building MooVeeMatch: A Mood-Based Movie Recommendation Program 🎥✨
&lt;/h2&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;As part of the Codecademy Computer Science curriculum, I recently completed a portfolio project: &lt;strong&gt;MooVeeMatch&lt;/strong&gt;. This program is a mood-based movie recommendation tool that allows users to discover films tailored to how they feel. Whether you're in the mood for something uplifting, adventurous, or mysterious, MooVeeMatch has you covered!&lt;/p&gt;

&lt;p&gt;In this blog post, I'll walk you through the inspiration behind the project, the technical details of its implementation, and key lessons I learned during development. If you're learning Python or working through Codecademy's curriculum, this might inspire you to build your own mood-based app!&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;About MooVeeMatch&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;MooVeeMatch is a &lt;strong&gt;command-line application&lt;/strong&gt; that takes user input (e.g., their mood) and returns a curated list of movies matching their vibe. The program is powered by a Python &lt;strong&gt;dictionary&lt;/strong&gt; (essentially a hash map) that stores moods as keys and lists of movies as values.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Features:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mood-Based Recommendations&lt;/strong&gt;: Search for movies by mood (e.g., uplifting, dark, funny, etc.).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interactive CLI&lt;/strong&gt;: A clean and user-friendly interface for browsing movie recommendations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Refactored Codebase&lt;/strong&gt;: Includes both the original implementation and a cleaner, more modular refactored version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Expandable Database&lt;/strong&gt;: Easily add more moods and movies to the database.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Technical Overview&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Data Structure&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The core of MooVeeMatch is a &lt;strong&gt;dictionary&lt;/strong&gt; that maps moods to movie lists. This is an example of a hash map in Python, providing efficient O(1) lookups for moods.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;movies_by_mood&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;uplifting&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The Pursuit of Happyness&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2006&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;A touching story about perseverance&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Soul&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2020&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;An inspiring animated story about life&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s purpose&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;dark&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Se7en&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1995&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;A gritty thriller about a serial killer&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The Dark Knight&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2008&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;A darker take on the Batman legend&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="c1"&gt;# More moods...
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Algorithms&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Search Algorithm&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The program uses the &lt;code&gt;startswith()&lt;/code&gt; method to find moods that match the user’s input.
&lt;/li&gt;
&lt;li&gt;Example: If a user types "upl", the program matches it to &lt;code&gt;"uplifting"&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Sorting Algorithm&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Movie lists are sorted alphabetically before being displayed using Python’s built-in &lt;code&gt;sorted()&lt;/code&gt; function.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Program Workflow&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Welcome Message&lt;/strong&gt;:
Users are greeted with a decorative ASCII banner.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mood Input&lt;/strong&gt;:
The program prompts users to enter the first few letters of their mood.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mood Matching&lt;/strong&gt;:
The program finds matching moods from the database using &lt;code&gt;startswith()&lt;/code&gt; and returns a list of matching options.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recommendations&lt;/strong&gt;:
Users confirm their mood and receive a list of recommended movies with titles, release years, and loglines.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Repeat or Exit&lt;/strong&gt;:
Users can explore other moods or exit the program.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Key Challenges and Refactoring&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Challenge: Nested Logic&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The original implementation had deeply nested loops and conditionals, making the code harder to read and maintain.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Solution: Refactoring&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;I refactored the code to improve modularity by breaking it into smaller, single-responsibility functions. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Before&lt;/strong&gt;: Mood matching and movie display were handled within the main loop.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;After&lt;/strong&gt;: Separate functions like &lt;code&gt;find_matching_moods()&lt;/code&gt; and &lt;code&gt;display_movies_for_mood()&lt;/code&gt; streamlined the code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s an example of a refactored function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;find_matching_moods&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_mood_letters&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Search for moods matching the input letters.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="n"&gt;mood&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;mood&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;movies_by_mood&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;mood&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_mood_letters&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This refactoring made the codebase more readable and easier to debug, especially as I expanded the movie database.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Lessons Learned&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Importance of Refactoring&lt;/strong&gt;:&lt;br&gt;&lt;br&gt;
Writing modular, clean code saves time in the long run. The refactored version of MooVeeMatch was not only easier to debug but also simpler to extend.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Using Hash Maps Effectively&lt;/strong&gt;:&lt;br&gt;&lt;br&gt;
Python dictionaries are powerful for storing and retrieving data efficiently. This project reinforced how to leverage hash maps in real-world scenarios.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Small Iterative Improvements&lt;/strong&gt;:&lt;br&gt;&lt;br&gt;
Working in small increments—writing a feature, testing it, and improving it—helped me maintain focus and avoid overwhelm.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CLI Design Matters&lt;/strong&gt;:&lt;br&gt;&lt;br&gt;
Even in a terminal-based program, user experience is key. Simple touches like a clean banner and well-structured output make a big difference.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;MooVeeMatch was a rewarding project that allowed me to apply what I’ve learned in Codecademy’s Computer Science curriculum to a real-world scenario. From handling user input to managing data efficiently, this project helped solidify my Python skills and taught me the value of clean, modular code.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Check Out MooVeeMatch on GitHub!&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;You can find the full codebase here: [&lt;a href="https://github.com/CodeWizardX1/MooVeeMatch" rel="noopener noreferrer"&gt;GitHub Repository Link&lt;/a&gt;](#)&lt;br&gt;&lt;br&gt;
Feel free to clone it, try it out, and contribute if you’d like!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Building a Classic Hangman Game in Python with Category Selection</title>
      <dc:creator>CodeWizardX1</dc:creator>
      <pubDate>Wed, 25 Sep 2024 01:51:28 +0000</pubDate>
      <link>https://dev.to/codewizardx1/building-a-classic-hangman-game-in-python-with-category-selection-396j</link>
      <guid>https://dev.to/codewizardx1/building-a-classic-hangman-game-in-python-with-category-selection-396j</guid>
      <description>&lt;p&gt;As part of Codecademy's Computer Science Career Path, I was assigned to create a Python terminal-based game for my first portfolio project. I wanted to build something fun and engaging, so I decided to recreate the classic Hangman Game, but with a twist: category selection.&lt;/p&gt;

&lt;p&gt;Instead of guessing a randomly selected word, the player can choose a category (such as Animals, Countries, or Movies) to help guide their guesses. This makes the game more strategic and enjoyable, while also allowing me to showcase my understanding of Python fundamentals. Below is a breakdown of my approach and a walk-through of the code.&lt;/p&gt;




&lt;p&gt;Here’s a sneak peek of what the Hangman game looks like when running in the terminal:&lt;/p&gt;

&lt;p&gt;The player is welcomed with an introductory screen, selects a category, and begins guessing letters to uncover the hidden word. The game even prints out fun ASCII art to show the progress of the poor stickman with each wrong guess!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmfb0tbavhnw51j88nb5h.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmfb0tbavhnw51j88nb5h.gif" alt="hangman terminal game" width="562" height="912"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;I designed my Python Hangman game with simplicity and user engagement in mind. The game logic revolves around guessing a hidden word, and the player must try to figure it out one letter at a time. Here are some key parts of the code:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Category Selection:&lt;/strong&gt; The game starts by letting the player choose from a list of categories. I used a Python dictionary to organize words into categories like "Animals," "Movies," and "Cities." This adds a fun twist because players can focus their guesses based on the category.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Random Word Selection:&lt;/strong&gt; After a category is selected, the game randomly picks a word from that category. This is handled using Python’s random module, ensuring a different experience every time the game is played.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handling Guesses:&lt;/strong&gt; The player can guess one letter at a time. Correct guesses reveal the positions of the letter in the word, while incorrect guesses add to the hangman’s figure. The game ends either when the word is fully guessed or when the hangman is fully drawn (after 6 incorrect guesses).&lt;/p&gt;

&lt;p&gt;ASCII Art: I used fun ASCII art to display the progress of the hangman, adding a visual element that players are familiar with from traditional Hangman games.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Check out the Code:&lt;/strong&gt;&lt;br&gt;
You can find the full source code for this project on my &lt;a href="https://github.com/CodeWizardX1/hangman_game" rel="noopener noreferrer"&gt;GitHub repository.&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Developing this Hangman game as part of Codecademy’s portfolio project was a great way to practice core Python concepts like dictionaries, loops, and conditionals while also creating something that’s both fun and nostalgic. I may add further enhancements at a later date.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
