Skip to content

SaiShankar93/bug-bash-ide

Repository files navigation

This is a Next.js project bootstrapped with create-next-app.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.

This project uses next/font to automatically optimize and load Inter, a custom Google Font.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

CodeContest Platform

A platform for hosting coding contests with a LeetCode-style interface.

Setting Up Contest Questions

LeetCode-Style Questions with Driver Code

The platform uses a driver code approach similar to LeetCode, where participants implement specific functions that are tested against test cases. This separates the implementation logic from input/output handling.

Example for Python:

  1. Problem Statement:
Write a function `two_sum(nums, target)` that takes an array of integers and a target integer, and returns the indices of two numbers such that they add up to the target.

Example:
Input: nums = [2, 7, 11, 15], target = 9
Output: [0, 1]
Explanation: Because nums[0] + nums[1] = 2 + 7 = 9
  1. Starter Code:
def two_sum(nums, target):
    # Your implementation here
    pass
  1. Driver Code:
def main():
    # Parse input
    lines = input_data.strip().split('\n')
    nums = list(map(int, lines[0].replace('[', '').replace(']', '').split(',')))
    target = int(lines[1])
    
    # Call participant's function
    result = two_sum(nums, target)
    
    # Format and print output
    print(result)

main()
  1. Solution Code:
def two_sum(nums, target):
    seen = {}
    for i, num in enumerate(nums):
        complement = target - num
        if complement in seen:
            return [seen[complement], i]
        seen[num] = i
    return []
  1. Test Cases:
    • Input: [2,7,11,15]\n9
    • Expected Output: [0, 1]

Example for Java:

  1. Problem Statement:
Write a function `int[] twoSum(int[] nums, int target)` that takes an array of integers and a target integer, and returns the indices of two numbers such that they add up to the target.
  1. Starter Code:
class Solution {
    public int[] twoSum(int[] nums, int target) {
        // Your implementation here
        return new int[0];
    }
}
  1. Driver Code:
public static void main(String[] args) {
    // Parse input
    String[] lines = input_data.trim().split("\\n");
    String numStr = lines[0].replace("[", "").replace("]", "");
    String[] numStrs = numStr.split(",");
    int[] nums = new int[numStrs.length];
    for (int i = 0; i < numStrs.length; i++) {
        nums[i] = Integer.parseInt(numStrs[i].trim());
    }
    int target = Integer.parseInt(lines[1]);
    
    // Call participant's solution
    Solution solution = new Solution();
    int[] result = solution.twoSum(nums, target);
    
    // Format and print output
    System.out.print("[");
    for (int i = 0; i < result.length; i++) {
        System.out.print(result[i]);
        if (i < result.length - 1) {
            System.out.print(", ");
        }
    }
    System.out.println("]");
}

How Driver Code Works

When a participant submits their solution:

  1. The platform combines their code with the driver code
  2. For each test case, the driver code:
    • Processes the test input
    • Calls the participant's function with the processed input
    • Formats the output from the participant's function
    • Compares it with the expected output

This approach:

  • Allows participants to focus on implementing algorithms
  • Provides consistent testing across submissions
  • Standardizes input/output handling
  • Matches the experience on platforms like LeetCode, HackerRank, etc.

About

Bug Bash is a coding contest platform where participants debug code and compete to fix bugs. Join existing contests with a unique code or log in as an admin to create new contests.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors