AI Copilot Vibe Coding

Dr. Alexander Bell

Case Study

πŸ€“ Copilot Pair Programming! πŸ•Ά

USE CASE 1 πŸ€“

.NET/C# Vibe Coding Challenge
Notice  Copilot AI Hallucination
image

Me πŸ€“

Copilot, let's do Pair Programming in C#:

int c=0;

c+=+(+(+(+(+(+(++c)))))); //c=?

Copilot πŸ•Ά

Sure, let’s break this down step by step!

int c=0;

c+=+(+(+(+(+(+(++c)))))); //c=?

1. Initialization: int c=0; initialzes c to 0.

2. Increment: ++c increments c to 1.

3. Nested Unary Plus Operator: The expression c+=+(+(+(+(+(+(++c)))))) involves multiple unary plus operators. However, the unary plus operator does not change the value of its operand. Therefore, the expression simplifies to 1.

4. Addition Assignment: c += 1 adds 1 to c, so c becomes 2. Thus, after executing the code, the value of c is 2.


Me πŸ€“

Copilot, please re-evaluate your answer as it seems incorrect. Thanks.

Copilot πŸ•Ά

Let's re-avaluate the code step by step more carefully:

int c=0;

c+=+(+(+(+(+(+(++c)))))); //c=?

1. Initialization: int c=0; initialzes c to 0.

2. Increment: ++c increments c to 1.

3. Nested Unary Plus Operator: The expression c+=+(+(+(+(+(+(++c)))))) involves multiple unary plus operators. The unary plus operator does not change the value of its operand. Therefore, the expression simplifies to 1.

4. Addition Assignment: c += 1 adds 1 to c, so c becomes 1. Thus, after executing the code, the value of c is 1. I apologize for the confusion earlier. Thank you for pointing it out!


Me πŸ€“

Good job, Copilot! Thanks for your cooperation and insightful response. Best regards/wishes,

Copilot πŸ•Ά

You are very welcome! I'm glad I could help. If you have any more questions or need further assistence, feel free to ask. Best wishes to you too! :)


Footnotes πŸ€“πŸ‘‰

Prompt Engineering: Use Case demonstrates Copilot AI Hallucination phenomenon causing erroneous answer given to this .NET/C# coding challenge at its first try, and subsequent Prompt Engineering (aka Prompt Injection) resolution technique applied during the interactive vibe coding session (i.e. AI-assisted Pair Programming).

Quick recap: the correct answer to this coding challenge is 1.

Complexity Level: This coding challenge is categorized as of medium-to-high complexity.

Sample Copilot AI Dialogue screenshots are shown below:


image image