ScalerTech

Get the latest updates from Scaler Tech community

Follow publication

AI-Powered Competitive Coding: Your Path to Success

--

Embrace the Future of Programming with AI’s Support

Illustration of Competitive coding companion
Competitive Coding Companion | Web illustrations using Storyset

French, Mandarin, and Spanish — everyone wants to learn a new language and expand their knowledge of a new culture. However, as our lives increasingly revolve around technology, there are other languages that are an immense asset- Programming languages.

Word cloud of programming languages
Programming Languages

Learning a new programming language is more than just a valuable addition to one’s portfolio; it has become an indispensable skill in our digital age. As virtual platforms replace traditional classrooms, and apps like Notion streamline our note-taking (saying this while using it to write the blog 😂), even something as simple as ordering takeout through Zomato involves the language of code working behind the scenes. And I can go on about the essence of learning a new programming language, but I believe my argument is now clear and compelling.

What will help you gain an edge?

Let’s delve into how one can truly excel in the world of programming. This is where competitive coding comes into play, and it’s just “an intimidating word for problem-solving using some programming language”. Yeah, and I don’t think there is anything else to say about it. You can get very complex definitions for this like the example presented below from chat GPT. But rest assured, The concept is as straightforward as I described it.

GPT definition for competitive coding
GPT definition for competitive coding

But when it comes to practising competitive coding, things can get tricky, much like doing a workout. The concept is simple: “training your body to gain strength and balance” but the execution is where the challenge lies. Learning a programming language may be easy, but it becomes your most potent asset when you consistently practice it, and competitive coding offers no better way to achieve that.

The New Era of Competitive Coding with AI

I believe we are in a new era for competitive coding because it has never been easier to adopt it as a habit. There are numerous platforms and excellent educational resources available, including AI tools like Large language models (LLMs) such as Chat GPT, which have become key enablers. In the past, resources were scarce, and there was little support available. Now, with AI assistance like Chat GPT, individuals can jump-start their competitive coding journey, benefiting especially those in the early stages.

The ease and potential of AI usage have grown tremendously, and accessibility has significantly improved over the past years.

In the following discussion, I will explain how you can utilize Chat GPT as your competitive coding companion, drawing insights from Scaler’s approach (based on first-hand information 😜).

GPT- Your competitive coding companion

Your competitive coding companion
Your competitive coding companion

Step 1: Set GPT Thermostat 🌡️

There is one key point we should address first. When generating responses from GPT, it can generate either from pure imagination or based on real facts. You can control this behaviour using the ‘Temperature’ argument, which ranges from 0 to 2. For the task of problem-solving, a good range is typically 0.5 to 0.9. This allows GPT to be innovative while avoiding excessive hallucinations.

To specify the ‘Temperature’ in the GPT playground, there is a direct option for that. However, when using a GPT chatbot, you can set the ‘Temperature’ at the start of your conversation like this:

use “temperature” value x on our conversation

A fun activity to try 💻, set a high-temperature value and ask some questions about non-existing things as I asked about the red peacock. Then ask the same question with a low-temperature value.

Example for a high-temperature value(2)

High-temperature example
High-temperature example

Same example for a low-temperature value(0)

Low-temperature example
Low-temperature example

This shows how temperature can affect your response and stop GPT from hallucinating.

Step 2: Know your stage 🧐

A comic strip by Monkey user

When working on a coding problem, it’s common to encounter multiple stages where you might get stuck, and sometimes these stages can appear quite similar. To effectively overcome these obstacles, it’s crucial to pinpoint the key issue causing the blockage. Let’s explore each stage and how you can recognise them:

  1. The Problem Statement Stage: This is the initial stage. To begin, try explaining the problem to someone else. Following that, attempt to create your input test case and calculate the expected output. If you can accomplish these two tasks, you have cleared this stage.
  2. The Ideation Stage: At this stage, you need to develop a common logic that can be applied to multiple test cases without altering the core idea. If you can build one you can move ahead.
  3. The Approach Stage: We will delve deeper into this stage in the “Implementation: Logical” section. The fundamental concept is to ensure that your approach covers all cases without failures. Failures can occur due to various reasons, such as missing edge cases, or exceeding time or memory limits.
    Identifying issues like Time Limit Exceeded (TLE) or Memory Limit Exceeded (MLE) is relatively straightforward. As these issues are caused when your approach was right but not for larger test cases as the compiler was not able to generate an output within the bounds and hence it throws out an error specifying the error type.
  4. The Implementation: Syntax Stage: This stage is the easiest to recognize, as it is indicated by any compilation errors you encounter while running your code. These errors usually relate to incorrect syntax or programming language rules.
  5. The Implementation: Logical Stage: As mentioned earlier, this is where it becomes tricky. Both having the wrong approach and incorrectly implementing the right approach can lead to failed test cases. For now, let’s consider these two situations together, and there are two ways you can seek help from Chat GPT, which we’ll discuss in the next section.

Moving forward, let’s explore how you can utilize Chat GPT to assist you with these coding problem-solving stages.

Step 3: Start prompting ⌨️

To make the most of GPT as your problem companion, follow these steps to set up the conversation (Also I have added an example of a full conversation with GPT at the end of this section):

Set the Role, Parameters, and Tone:

Role: Start by specifying the role of GPT, which is your problem-solving companion

Tone: You can also indicate the desired tone of the responses, such as concise, long, stepwise, or any style that suits your learning preferences.

Parameters: It’s essential to set the right parameters to ensure GPT provides the level of assistance you need. By default, GPT might try to offer complete solutions, but you can avoid that by instructing the model to provide hints or point you in the right direction. Emphasize that you don’t want direct solutions or code. You can customize this setup further based on your specific requirements to tailor your assistant.

In the end, your prompt will look like this:-

You are <role>, who will provide <tone> response by <parameter>.
For the problem delimited by angular brackets.
<problem_description>
eg.
You are my personal problem-solving companion, who will provide me with a concise response
by either providing me hints or pointing me in the right direction and you should never give
me direct solutions or code. For the problem delimited by angular brackets.
<
print a pyramid pattern
>

And now the setup is complete for your assistant. You can begin asking questions based on the stage where you are currently stuck.

Getting help for Problem statement

Here you can simply ask the model to explain the problem statement in simpler terms. A fun thing to try can be asking the model for analogies for the problem. It will give you creative examples which can help you build a new perspective.

It’s essential to note that relying on the model to explain test cases or visualize the problem statement might not always yield reliable responses. So, while these options are available, it’s best to use them with caution.

Getting help for Ideation

Here you can start asking for hints for the approach, the order which will work best is:

  1. Ask for hints about the key challenges- It is the first thing you should figure out in the problem.
  2. Ask for hints about the key insights- the next step after finding the challenges is what insight you can gain from it.
  3. Ask for hints about the intuition- after figuring out the challenges and insights you should start building your intuition around it.
  4. Ask for hints about data structure and algorithm- building an intuition will lead to the planning of what DS/Algo concept you can use to implement that
  5. Ask for hints for the solution- the last thing will be the solution building upon all the points discussed above.

And these 5 steps should help you get started with the approach.

Getting Help with Implementation

Here comes the last stage in problem-solving implementation, And here you can face multiple issues-

Syntax- Getting help with code errors is easy. Just share your code and the specific error you’re facing, and ask for guidance on resolving the issues. Please request that GPT does not provide a complete fixed code to avoid potential inaccuracies. Instead, rely on GPT to point out syntax issues and guide you towards solutions. You can repeat the process until all syntax issues are resolved.

Note: While providing an external text like code, errors which are not part of the prompt you should always tell GPT what part of the prompt is delimited by like please help me with my code delimited by square brackets [your code]

Logic- Once all syntax issues are resolved, you may encounter two cases. First, if you encounter Time Limit Exceeded (TLE) or Memory Limit Exceeded (MLE), it is advisable to ask GPT for the maximum acceptable time and memory complexity based on the given constraints in the problem description(ensure you have provided it in the problem description). This will help you understand the efficiency requirements before exploring alternative approaches. Additionally, you can request suggestions for a more efficient solution or improvements to your current approach.

The second case is encountering logical errors. Here, you have two options. Firstly, you can ask GPT to assess your approach even before implementing it. Just provide your proposed approach and ask GPT to evaluate it for you. The other thing you can do is fix logical issues in your code, but here you can’t simply ask “Please find logical errors” to GPT as it will mostly give wrong responses.

To fix this you should give more context to GPT to compute. Consider providing generic steps that GPT can use as a basis for generating tailored advice based on your specific problem and solution. For instance, you could use something like:

Please find the issue in the code delimited by triple backticks
```code```

please follow these steps to provide help:
1. Now, analyze the code to determine if it will work as a solution for the problem.
2. Identify any logical issues that may prevent it from being a correct solution.
3. Attempt to fix the logical issues and check if the solution works. If it doesn't, repeat steps 1-2. Otherwise, proceed to step 4.
4. Help the user address those logical issues.
5. Check the validity of your response by using generated response to fix the code and see if it works.
6. Fix mistakes in your response.

Please make sure you don't provide me with any form of code, and provide response in form of
<brief about the issue>
<how to resolve it>

You can go through the example for the full conversation with chat GPT where I am using these principles — Conversation with Competitive Coding Companion

Important

While trying any prompt please make sure a few things, your prompts have a clear structure and no typos. Also, You are using delimiters for providing external text as mentioned above. These small things keep GPT in check and ensure it is not going off the track. You can provide your prompts in the comment section and I can assess them for you and suggest how you can improve them.

Great! With this, you should be able to use GPT to its full potential in helping you solve problems, and improve your competitive coding skills.

Let’s see how Scaler did it

Newspost about Scaler using GPT

There are multiple news posts regarding how Scaler has embraced cutting-edge AI, utilizing a model like Chat GPT to revolutionize the learning experience. Scaler leverages the same core principles we discussed earlier to assist learners throughout their journey. It is the first-hand usage of those principles.

For those who don’t know, Scaler is an up-skilling platform that helps users build technical skills from the ground up, starting with competitive coding as their first stage. As most of the audience in Scaler is new to programming due to the nature of the platform, there was a crucial requirement of enablers which can help learners when they get stuck on a problem and these enablers were Teaching Assistants. But with the introduction of Chat GPT, the possibilities became intriguing. Every mind in scaler was thinking- “How can we use it to be a better alternative to teaching assistant due to its obvious pros like availability, quick SLAs and quality”. To explore this idea, Scaler began experimenting with GPT’s assistance, providing learners with nudges in the right direction without revealing a full solution.

The groundwork for this unique approach was set, and a comprehensive companion was developed. Learners could seek help with their doubts, and Scaler’s system adeptly gathered relevant information to create specially designed prompts. These prompts were then sent to GPT, generating appropriate responses to assist the learners effectively.

Scaler Problem-solving companion
Scaler Problem-solving companion

Currently, learners trigger assistance, but the team at Scaler is actively working on an automated system. This system will intelligently recognize when a learner is stuck based on their behaviours and provide timely help without requiring manual activation.

With AI as an ally, Scaler has transformed the way learners tackle challenges, opening up new possibilities and revolutionizing the future of upskilling. The integration of GPT into the learning process has streamlined problem-solving and made the competitive coding journey an enriching experience for every learner.

In conclusion, competitive coding can be an incredibly rewarding hobby, and the vast potential of GPT can assist you in ways you may not have imagined.

I hope you enjoyed reading the blog and gained valuable insights from it. If you have any questions or wanna share your experience drop a comment. Feel free to reach out in any form. Happy coding! 🔥

--

--

Published in ScalerTech

Get the latest updates from Scaler Tech community

Written by Striker

I am a young programmer pursuing a bachelor in Computer Science, exploring and overthinking everything in my way and trying to share my experience on Medium.

No responses yet

Write a response