The Prompt Library
CodingDebugging

Fix a Logic Bug

Describe unexpected behavior and get help correcting your logic.

Select Model:

Prompt:

I need help fixing a logic bug in my code. The program isn't working as expected, and I believe there's an issue with my algorithm or the way I've structured my logic. CODE WITH BUG: ``` [CODE_WITH_BUG] ``` PROBLEM DESCRIPTION: - Expected behavior: [EXPECTED_BEHAVIOR] - Actual behavior: [ACTUAL_BEHAVIOR] - Test cases/inputs: [TEST_CASES] ADDITIONAL INFORMATION: - Language/Framework: [LANGUAGE_OR_FRAMEWORK] - Purpose of the code: [PURPOSE] - Parts I suspect are problematic: [SUSPICIOUS_PARTS] - What I've tried already: [ATTEMPTED_FIXES] - Relevant error messages (if any): [ERROR_MESSAGES] Please help me with: 1. Bug Identification - What's causing the unexpected behavior - How the code is currently executing - Where my logic is flawed 2. Solution Implementation - How to fix the code - Clear explanation of the changes - Why these changes solve the problem 3. Conceptual Understanding - What concept or pattern I might be misunderstanding - The correct approach to this problem - Any relevant programming principles 4. Prevention Advice - How to prevent similar bugs in the future - Testing strategies for this type of code - Best practices relevant to this scenario I want to not only fix this specific issue but also learn how to avoid similar mistakes in the future.

Related Prompts

Other prompts you might find useful

CodingDebugging

General Debugging Assistant

Walk through a bug or error step-by-step to find the issue.

6 models availableView details
CodingDebugging

Read and Explain Stack Trace

Interpret error logs or stack traces from any programming language.

6 models availableView details
CodingDebugging

Fix a Logic Bug

Describe unexpected behavior and get help correcting your logic.

6 models availableView details
CodingDebugging

Identify Edge Case Failures

Find edge cases that might break your code or cause silent errors.

6 models availableView details