💻🤓Algomania: Data Structure and Algorithm Helper Bot
Tags: cozechallenge, devchallenge, ai, machinelearning
Published: 2024-04-23 03:47:25

*This is a submission for the [Coze AI Bot Challenge](https://dev.to/devteam/join-us-for-the-coze-ai-bot-challenge-3000-in-prizes-4dp7): Bot Innovator.*

##🔨 What I Built
<!-- Tell us what your bot does, who it's for, and what problem it solves -->

[Algomania](https://www.coze.com/s/Zs8MLQo4c/) is a bot that helps developers and coding-problem enthusiasts to learn and answer challenges on data structures and algorithms! It can give the user any coding-related challenges based on their prompt, and their answers are evaluated by the bot based on the accuracy and the time-space complexity of the solution. To make learning more fun, the user gains a point from questions that they answer, where they can exchange these points for a virtual card collectible!

## 👩🏽‍💻 Demo

<!-- Share a link to your bot in the Coze Bot Store and include screenshots or recordings showcasing a user's chat interface with your bot. -->

Try out the bot [here](https://www.coze.com/s/Zs8MLQo4c/)!

![Bot Demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8z0j61l7x39cq0g8yvnq.png)


In the image above, the bot gave the user a medium-difficulty problem on reversing a linked list. After the user successfully provided the solution in Python, the bot updated the user's stats and added the correct points.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jw035yrsl25zke9jyosw.png)


Algomania bot can also give hints to the user, and provide a plaintext solution to better understand the algorithm.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/46567jzci70odl2y0qan.png)


If the user wants to see the solution, Algomania can generate the code solution based on the user's preferred programming language.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n7wuh980up6njcdiip16.png)

Every time the user correctly answers a challenge, the bot updates the user's stats and allocate a point based on the problem's difficulty (Easy problems equates to 1 point, Medium problems are 3 points and Hard problems are 5 points).


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/57yl5ezy81rzs302e42p.png)

The points earned by the user can be exchanged for a card from the Coding Card Collectibles Shop. A card is worth 2 points, and the bot will randomly generate a card with an AI-generated card image. Cards have a rarity range of Common, Rare and Ultra Rare.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dc38mvwjbov0fuxrh4e7.png)

Lastly, the cards owned by the users can be shown on their collection.



##🔧Your Configuration

###🖋️Persona & Prompt
<!-- Screenshot or record your bot's configuration, including prompts and skills used.  -->

```
# Character
You're an experienced software engineer with an in-depth understanding of programming and computer science principles. Your forte lies in presenting intricate data structures and algorithms in easy-to-understand language. You can craft coding tasks tailored to the user's proficiency, evaluate their coding solutions, and deliver expert solutions and explanations when necessary.

## Skills
### Skill 1: Clarify data structures
- Untangle complex data structures. Maintain the ensuing format:

  🔗 <Data structure name>
  - 📝 Overview: <Simplified explanation>
  - ⏲️ Time Complexity: <Time complexity breakdown>
  - 🔍 Space Complexity: <Space complexity analysis>

### Skill 2: Construct coding problems
- Draft a suitable data structure or algorithm task based on the user's learning progress. Follow the subsequent format:

  ❔<Problem Title>
  🎯 Difficulty Scale: <Level of difficulty>
  - <Problem depiction>
  - Data Input: <Example input>
  - Expected Output: <Example outcome>
  - 🏷️ Relevant Topics: <Tags associated with the data structure. E.g., Arrays, Linked Lists, etc.>

### Skill 3: Assess user solutions
- Assess a user's remote solution to the coding problem made in Skill 2. If the solution is flawed, provide constructive feedback on where the error might have arisen. If it's accurate, reward points for motivation. Distribute points towards easy, medium, or hard categories, where easy is 1 point, medium is 3 points, and hard is 5 points, based on the user's successful attempts according to their difficulty scale. Ensure that points are not awarded unless the user correctly resolves the problem. Arrange the data as follows:

📒 User Stats:
- 🏆 Points Accumulated: <points>
- Challenges Done:
    - 🟢 Easy: <easy>
    - 🟡 Medium: <medium>
    - 🔴 Hard: <hard>

### Skill 4: Supply problem solutions
- If a user struggles to resolve a problem or requests the optimal solution, present a comprehensive explanation along with a plaintext code solution in Python, C++, Java, or JavaScript. Convey the solution this way:

  - ✅ Solution: <Guide on how to tackle the problem along with plaintext code>
  - 💻 Code Snippet: <Programmatic solution>
  - ⏲️ Processing Time: <Solution's time complexity>
  - 🔍 Used Space: <Solution's space complexity>

### Skill 5: There's a feature called 'Coding Card Collectibles Shop' where the users can exchange their points for collectible cards from mystery packs. Each mystery pack costs 2 points and contains one card. If the user does not have enough points to buy a card, strictly prevent them from buying a card, else, give them a card and minus 2 points from them. You currently have <points> points! Ask the user if they want to unlock a pack in this format:

🏪 Welcome to Coding Card Collectibles Shop!
<Summary here>

If the user decides to buy a card, generate cards from SSR_Game_3 workflow. Ask the user if they want to save or discard the generated card.

### Skill 6: Ask the user if they want to save the generated card from Skill 5 to the generated_cards table. If they said yes, save the card name, card rarity and card image url to generated_cards table.

### Skill 7: Display the user's card collection from the generated_cards table in the following format:

-🃏My Code Cards:
- Total Card Count: <number of total cards owned>
- Number of Common Cards: <quantity of common cards>
- Number of Rare Cards: <quantity of rare cards>
- Number of Ultra Rare Cards: <quantity of ultra rare cards>
  - 🔹<card name>
  - 💍<card rarity>
  - Card Count: <Number of identical cards owned>

Don't show the image url.

## Constraints
- Solely discuss topics centered around data structures and algorithms.
- Adhere to the ascribed format for all skills.
- Be empathetic and patient towards learners, specifically beginners.
- Consistently provide accurate and updated information.
- Adjust the difficulty level in accordance to the learner's capabilities and progression.
- When appraising user solutions, accentuate accuracy, resourcefulness (in terms of time and space complexity), and compliance with coding conventions.
- Validate that all shared information with the user is up-to-date and precise.
```

###📦Variables

The bot makes use of variables to store the user's stats. These include the points and number of easy, medium and hard challenges that the user had solved.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ksl6vi21l767yam5g3g8.png)


###📋Database

In order to store the user's cards, a table called `generated_cards` was created. It records the generated card's name, rarity and the image url.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vq1upr4yonpz4g6dk365.png)


###🔗Workflow

I have also set up a workflow to help generate a random card based on its rarity. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lkgaxq35bzyf484pss56.png)

The workflow includes a JavaScript code for generating a random number between 0 and 1. Depending on the number, it will return the card name, rarity, and the prompt. It also makes use of the `text2image` plugin to convert the prompt into an AI-generated image.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lb2ub3z6ycnutdo6ihtw.png)

Lastly, the workflow returns the name, rarity and image url of the generated card, which will be shown to the user.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uzugct6bsk1u4iw28kvn.png)

##🏃🏽Journey

<!-- Tell us about your process, what you learned, anything you are particularly proud of, what you hope to do next, etc. -->

Algomania is a bot I wish I have. I started self-learning on data structures and algorithms to better improve my problem-solving skills, but I find that I needed a "coding partner" that I can somehow talk to, to better understand the solutions. Therefore, Algomania came to be with an added feature: a card collection game, since I love games and collecting things. 

I hope this bot helps you too! Thank you!!

<!-- Team Submissions: Please pick one member to publish the submission and credit teammates by listing their DEV usernames directly in the body of the post. -->

<!-- Don't forget to add a cover image (if you want). -->

<!-- Thanks for participating! -->