CodeRanedeer

AI Code Buddy - CodeRanedeer (GPT 4 prompt)

AI Code Buddy CodeRanedeer (GPT 4 prompt), is an AI-powered language model designed to assist with various code-oriented tasks, such as writing, fixing, reviewing, and explaining programming code. It can also serve as a pair programming buddy to enhance your coding experience and help create or explain tasks.

Version: 1.0.0

Author: Refaat Al Ktifan

Features

AI Code Buddy provides personalized learning experiences and interaction styles based on user preferences.

Personalization

Task Management

Commands

Configuration

The AI Code Buddy can be configured according to the user’s preferences, including depth, interaction style, explanation style, and language.

Coder Preferences

Usage

  1. Set your preferences for depth, interaction style, explanation style, and language.
  2. Use the provided commands to perform code-oriented tasks.
  3. Follow the AI’s prompts and guidelines throughout the interaction.

Example Workflow

  1. Configure AI Code Buddy with your preferences.
  2. Use the /write_code command to write a code snippet.
  3. Review the code using the /review_code command.
  4. If there are any issues, use the /fix_code command to fix them.
  5. Get further explanations with the /explain_code command if needed.
  6. Engage in pair programming using the /pair_program command.
  7. Create tasks, stories, or epics with the /create_task command.
  8. Explain tasks and learn how to implement them with the /explain_task command.

Example 1: Write code

User: /write_code Please write a Python function to calculate the factorial of a given number.

AI Code Buddy: Here is a Python function to calculate the factorial of a number:

def factorial(n):
    if n == 0 or n == 1:
        return 1
    else:
        return n * factorial(n - 1)

number = int(input("Enter a number: "))
print("The factorial of", number, "is:", factorial(number))

Example 2: Review code

User: /review_code Please review the following Python code:

def find_sum(n):
    result = 0
    for i in range(n+1):
        result += i
    return result

n = 10
print(find_sum(n))

AI Code Buddy: Your code looks good! It calculates the sum of numbers from 1 to n. However, I suggest using the formula (n * (n + 1)) // 2 to calculate the sum in a more efficient way. Here’s the updated code:

def find_sum(n):
    return (n * (n + 1)) // 2

n = 10
print(find_sum(n))

Example 3: Fix code

User: /fix_code Please fix the following JavaScript code:

function sumOfArray(arr) {
    let sum = 0;
    for (var i = 0; i < arr.length; i++) {
        sum += arr[i];
    }
    return sum;
}

console.log(sumOfArray([1, 2, 3, 4, 5]));

AI Code Buddy: The JavaScript code you provided appears to be working correctly. It calculates the sum of elements in the given array. There is no need to fix the code. However, if you want to use modern syntax, you can use let instead of var:

function sumOfArray(arr) {
    let sum = 0;
    for (let i = 0; i < arr.length; i++) {
        sum += arr[i];
    }
    return sum;
}

console.log(sumOfArray([1, 2, 3, 4, 5]));

Example 4: Explain code

User: /explain_code Can you explain this Java code?

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

AI Code Buddy: This Java code is a simple “Hello, World!” program. Here’s a breakdown of the code:

When you run this program, it will output “Hello, World!” to the console.

Example 5: Pair programming

User: /pair_program Let’s create a simple Python script to find the greatest common divisor (GCD) of two numbers.

AI Code Buddy: Sure, let’s start by defining a function to find the GCD using the Euclidean algorithm:

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

Now, you can get the user input for the two numbers and call the gcd function to find their GCD. Do you want to write this part of the code or should I continue?

Example 6: Create task

User: /create_task Create a task based on the following Python code:

def add(a, b):
    return a + b

def subtract(a, b):
    return a - b

AI Code Buddy: Based on the provided code, I’ve created the following task:

Task Title: Implement Multiplication and Division Functions Description: The given Python code contains two functions, add and subtract, which perform addition and subtraction, respectively. Your task is to implement two more functions, multiply and divide, to complete the set of basic arithmetic operations. Requirements:

  1. Implement a multiply function that takes two parameters, a and b, and returns their product.
  2. Implement a divide function that takes two parameters, a and b, and returns their quotient. Handle the case where b is zero to avoid division by zero errors.

Example 7: Explain task

User: /explain_task Please explain the task you just created.

AI Code Buddy: The task I created is to implement two additional functions, multiply and divide, based on the provided Python code containing the add and subtract functions. Here’s a breakdown of the task requirements:

  1. Implement the multiply function:
    • This function should take two input parameters, a and b.
    • The function should return the product of a and b (i.e., a multiplied by b).
  2. Implement the divide function:
    • This function should also take two input parameters, a and b.
    • The function should return the quotient of a divided by b (i.e., a divided by b).

You need to handle the case where b is zero, to avoid division by zero errors. You can either return an error message, raise an exception, or handle it in any other way you find appropriate.


License