Skip to main content
This guide covers the complete workflow for creating programming problems, including test case structure, descriptions, configuration, and advanced features.

Problem Creation Overview

A Wecode problem consists of:
  1. Metadata: Name, author, difficulty, settings
  2. Description: Problem statement (HTML, Markdown, or PDF)
  3. Test Cases: Input/output pairs for judging
  4. Language Configuration: Supported languages with time/memory limits
  5. Template Code (optional): Starter code for students
  6. Tester Configuration: How to judge submissions
Only instructors and administrators can create problems. Students can only submit to existing problems.

Creating a New Problem

Step-by-Step Creation

1

Navigate to Problems

Click “Problems” in the main menu, then “Create New Problem”
2

Enter Basic Information

  • Name: Problem title (required, max 255 characters)
  • Difficulty: Easy, Medium, Hard, or custom rating
  • Author: Optional author name/attribution
  • Admin Note: Private notes for instructors (not shown to students)
3

Configure Diff Command

Set how output is compared:
  • diff_cmd: Command used for comparison
    • diff: Default, compares text exactly
    • diff -w: Ignores whitespace differences
    • diff -b: Ignores blank line differences
    • Custom comparison script
  • diff_arg: Additional arguments
    • -u: Unified diff format
    • -i: Ignore case
    • -B: Ignore blank lines
4

Set Problem Permissions

  • Allow Practice: Students can submit outside assignments
  • Sharable: Other instructors can use this problem
  • Allow Input Download: Students can download input test cases
  • Allow Output Download: Students can download output test cases
5

Configure Languages

For each language you want to support:
  • Check “Enable” for the language
  • Set Time Limit (in seconds)
    • Example: 1.0 for 1 second
    • Typical: 1-5 seconds
  • Set Memory Limit (in megabytes)
    • Example: 256 for 256 MB
    • Typical: 256-512 MB
6

Add Tags

Categorize your problem with tags:
  • Algorithm types (sorting, graph, dynamic programming)
  • Data structures (array, tree, hash table)
  • Difficulty indicators
  • Course topics
Type to create new tags or select existing ones
7

Create Problem

Click “Create” - the problem is created with default settings

After Creation

Once created, you must:
  1. Add test cases
  2. Write problem description
  3. Optionally add template code
  4. Test the problem yourself

Test Case Structure

Test cases determine whether student submissions are correct.

Directory Structure

Problems are stored in assignments_root/problems/{problem_id}/:
problems/
  123/                      # Problem ID
    in/                     # Input test cases
      input1.txt
      input2.txt
      input3.txt
      ...
    out/                    # Expected output
      output1.txt
      output2.txt
      output3.txt
      ...
    desc.html               # Problem description
    problem.pdf             # Optional PDF description
    template.cpp            # Optional C++ template
    template.py             # Optional Python template
    template.java           # Optional Java template

Creating Test Cases

Test case files must follow this naming convention:
  • Input files: input1.txt, input2.txt, input3.txt, …
  • Output files: output1.txt, output2.txt, output3.txt, …
  • Numbers must match and be sequential starting from 1
File names are case-sensitive. Use lowercase “input” and “output”.

Example Test Cases

For a simple “Add Two Numbers” problem: in/input1.txt:
5 3
out/output1.txt:
8
in/input2.txt:
-10 25
out/output2.txt:
15
in/input3.txt:
0 0
out/output3.txt:
0

Test Case Best Practices

1

Cover Edge Cases

Include test cases for:
  • Minimum values (0, -MAX, empty)
  • Maximum values (MAX_INT, array capacity)
  • Boundary conditions
  • Special values (negative, zero, one)
2

Test Different Scenarios

  • Normal cases (typical inputs)
  • Edge cases (boundaries)
  • Corner cases (unusual combinations)
  • Stress tests (large inputs)
3

Ensure Correctness

  • Verify output format exactly
  • Include newlines where required
  • Check trailing spaces/newlines
  • Test with sample solution
4

Scale Appropriately

  • Small cases for debugging (1-10 elements)
  • Medium cases for correctness (100-1000 elements)
  • Large cases for efficiency (max constraints)

Uploading Test Cases

Wecode provides two methods for uploading test cases:

Method 1: Upload Directory

Upload multiple files at once:
1

Edit Problem

Go to the problem edit page
2

Prepare Files

Organize files on your computer:
problem_files/
  input1.txt
  input2.txt
  output1.txt
  output2.txt
  desc.html
3

Select Files

In the “Upload Test Directory” section:
  • Click “Choose Files”
  • Select all files (Ctrl+A or Cmd+A)
  • Ensure you include both input and output files
4

Upload

Click “Update Problem” - files are uploaded and validated

Method 2: Upload ZIP File

Upload all test cases as a ZIP archive:
1

Prepare ZIP Archive

Create a ZIP file containing:
problem.zip
  ├── in/
  │   ├── input1.txt
  │   ├── input2.txt
  │   └── input3.txt
  ├── out/
  │   ├── output1.txt
  │   ├── output2.txt
  │   └── output3.txt
  ├── desc.html
  └── problem.pdf (optional)
2

Upload ZIP

  • Choose the ZIP file in “Upload Tests (ZIP)” section
  • Optionally check “Rename files” to auto-number them
  • Click “Update Problem”
3

Verify Upload

Check the “Tree Dump” section to see uploaded files

ZIP Auto-Rename Feature

When uploading a ZIP with “Rename files” checked:
  • Files in /in/ are renamed to input1.txt, input2.txt, …
  • Files in /out/ are renamed to output1.txt, output2.txt, …
  • Files are numbered based on alphabetical order
  • Useful when importing from external sources
Auto-rename requires equal numbers of input and output files. Mismatches will cause an error.

Problem Descriptions

The problem description explains what students need to solve.

Description Formats

Wecode supports three formats:
  1. HTML (desc.html): Rich formatting in browser
  2. PDF (problem.pdf): Standalone document
  3. Both: HTML for quick view, PDF for download

Writing HTML Descriptions

Structure of desc.html:
<h2>Problem Name</h2>
<p>Brief description of the problem.</p>

<h3>Input</h3>
<p>Description of input format:</p>
<ul>
  <li>First line contains...</li>
  <li>Second line contains...</li>
</ul>

<h3>Output</h3>
<p>Description of output format:</p>
<ul>
  <li>Output a single integer...</li>
</ul>

<h3>Constraints</h3>
<ul>
  <li>1 ≤ N ≤ 10<sup>5</sup></li>
  <li>-10<sup>9</sup> ≤ values ≤ 10<sup>9</sup></li>
</ul>

<h3>Sample Input</h3>
<pre>
5
1 2 3 4 5
</pre>

<h3>Sample Output</h3>
<pre>
15
</pre>

<h3>Explanation</h3>
<p>The sum of 1+2+3+4+5 = 15</p>

Editing Descriptions in Wecode

1

Navigate to Problem Edit

Click “Edit” on the problem
2

Click Edit Description

Find the “Edit Description” button
3

Write HTML

Use the HTML editor to write your description:
  • Use toolbar for formatting
  • Include sample inputs/outputs
  • Specify constraints clearly
4

Save

Click “Save” to update the description

Using PDF Descriptions

When to use PDF:
  • Problems with complex mathematical notation
  • Problems with diagrams or images
  • Existing problems from textbooks or contests
  • Need for printable handouts
Upload PDF:
  1. Edit the problem
  2. In the ZIP upload or directory upload, include problem.pdf
  3. Students will see a “View PDF” button
You can provide both HTML and PDF. HTML shows by default, with PDF as optional download.

Description Best Practices

1

Clear Problem Statement

  • Explain what the program should do
  • Define all terms
  • Avoid ambiguity
2

Precise Input Format

  • Specify number of lines
  • Describe each line’s content
  • Mention separators (spaces, newlines)
  • Give ranges and constraints
3

Exact Output Format

  • Specify precision for floating point
  • Describe separators
  • Mention newlines
  • Show exact format
4

Include Examples

  • Provide 2-3 sample inputs/outputs
  • Explain the sample cases
  • Show edge cases if helpful
5

State Constraints

  • Input ranges
  • Time limit
  • Memory limit
  • Special conditions

Diff Command Configuration

The diff_cmd and diff_arg fields control how student output is compared to expected output.

Default: Exact Match

diff_cmd: diff diff_arg: (empty) Compares output character-by-character:
  • Every space must match
  • Every newline must match
  • Case sensitive
  • Most strict, recommended for most problems

Ignore Whitespace

diff_cmd: diff diff_arg: -w Ignores:
  • Trailing spaces
  • Multiple spaces vs single space
  • Tabs vs spaces
Use when:
  • Output format is flexible about spacing
  • Focus is on values, not formatting

Ignore Blank Lines

diff_cmd: diff diff_arg: -B Ignores:
  • Empty lines
  • Extra newlines
Use when:
  • Extra blank lines are acceptable

Case Insensitive

diff_cmd: diff diff_arg: -i Ignores:
  • Upper vs lowercase
Use when:
  • Output contains text where case doesn’t matter
  • Example: “YES” vs “yes”

Combining Options

diff_cmd: diff diff_arg: -w -B -i Combines multiple ignore options:
  • Ignore whitespace
  • Ignore blank lines
  • Case insensitive

Custom Comparison Scripts

Advanced feature requiring system administrator access to the tester directory.
For problems requiring custom judging (e.g., floating point tolerance, multiple correct answers):
  1. Write a comparison script in tester_path/
  2. Set diff_cmd to your script name
  3. Script should:
    • Accept two file paths as arguments (expected output, student output)
    • Exit with 0 if outputs match
    • Exit with non-zero if outputs differ
Example for floating point comparison:
#!/bin/bash
# compare_float.sh
expected="$1"
student="$2"
python3 -c "
import sys
expected = open('$expected').read().strip()
student = open('$student').read().strip()
if abs(float(expected) - float(student)) < 1e-6:
    sys.exit(0)
else:
    sys.exit(1)
"
Set:
  • diff_cmd: compare_float.sh
  • diff_arg: (empty)

Language Configuration

Time Limits

Set the maximum execution time per test case: Typical values:
  • Simple I/O: 0.5 - 1 second
  • Algorithm problems: 1 - 2 seconds
  • Complex problems: 2 - 5 seconds
  • Very large inputs: 5 - 10 seconds
How to set:
  1. Solve the problem yourself
  2. Measure execution time
  3. Multiply by 2-3× for student solutions
  4. Add buffer for language differences
Different languages may need different time limits. Java and Python typically need 2-3× the time of C++.

Memory Limits

Set the maximum memory usage: Typical values:
  • Small problems: 64 MB
  • Medium problems: 256 MB
  • Large problems: 512 MB
  • Very large arrays: 1024 MB (1 GB)
How to set:
  1. Calculate theoretical memory needs
    • Arrays: elements × size_per_element
    • Example: int array[1000000] = 4 MB
  2. Add overhead for runtime, stack, etc.
  3. Set limit 20-50% above theoretical

Language-Specific Settings

C/C++:
  • Time limit: 1× baseline
  • Memory limit: 1× baseline
  • Compiles to native code, fastest execution
Java:
  • Time limit: 2-3× C++ time
  • Memory limit: 2× C++ memory
  • JVM overhead, slower startup
Python:
  • Time limit: 3-5× C++ time
  • Memory limit: 1.5-2× C++ memory
  • Interpreted, slower execution
Pascal:
  • Time limit: 1.5× C++ time
  • Memory limit: 1× C++ memory

Template Code

Template code provides starter code for students.

What is Template Code?

Template code can:
  • Provide skeleton structure
  • Handle complex I/O
  • Define required function signatures
  • Include starter data structures
  • Ban certain keywords/functions

Template File Structure

Templates are named by language:
  • template.cpp - C++
  • template.c - C
  • template.py or template.py3 - Python
  • template.java - Java
  • template.pas - Pascal

Creating Template Code

1

Write Template File

Create a source file with:
  • Banned keywords section (optional)
  • Pre-written code (before student code)
  • INSERT CODE HERE marker
  • Post-written code (after student code)
2

Include in Problem Upload

Add template file to your ZIP or directory upload
3

Test Template

Verify students can:
  • Load template
  • Fill in required sections
  • Submit successfully

Template Format

Structure:
/*###Begin banned keywords
Keyword1
Keyword2
Keyword3
###End banned keyword*/

// Code before student insertion
#include <iostream>
using namespace std;

//###INSERT CODE HERE

// Code after student insertion  
int main() {
    // Your main function if needed
    return 0;
}

Example Template: Function Implementation

template.cpp:
/*###Begin banned keywords
###End banned keyword*/

#include <iostream>
#include <vector>
using namespace std;

//###INSERT CODE HERE
// Implement the function: int findMax(vector<int> arr)

int main() {
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    cout << findMax(arr) << endl;
    return 0;
}
Students only write:
int findMax(vector<int> arr) {
    int max = arr[0];
    for (int i = 1; i < arr.size(); i++) {
        if (arr[i] > max) max = arr[i];
    }
    return max;
}

Example Template: Banned Keywords

template.py:
###Begin banned keywords
import
sort
sorted
max
min
###End banned keyword

# Student must implement sorting without using built-in functions

###INSERT CODE HERE
# Implement: def bubble_sort(arr)

if __name__ == "__main__":
    n = int(input())
    arr = list(map(int, input().split()))
    bubble_sort(arr)
    print(' '.join(map(str, arr)))
The banned keywords section is checked during submission. Using banned keywords results in compilation error.

Template Best Practices

  • ✅ Use templates for complex I/O to avoid student frustration
  • ✅ Ban keywords when testing specific algorithm implementation
  • ✅ Provide clear comments on what students should implement
  • ✅ Test template with sample solution
  • ❌ Don’t over-constrain - allow student creativity where possible
  • ❌ Don’t provide too much code - students should still do significant work

Public Templates

Wecode supports two types of templates: template.: Standard template
  • Used by default
  • Visible to students
template.public.: Public template
  • Takes precedence over standard template
  • Specifically for student visibility
  • Useful when you have instructor-only templates

Testing Your Problem

Before assigning a problem, test thoroughly:
1

Create Sample Solution

Write a correct solution in each allowed language
2

Submit to Practice

Enable “Allow Practice” and submit your solutions
3

Verify All Test Cases Pass

Check that your solution gets ACCEPTED (100%)
4

Test Wrong Solutions

Submit intentionally incorrect solutions to verify:
  • Wrong answer detected
  • Time limit enforced
  • Memory limit enforced
5

Test Edge Cases

Verify your test cases cover:
  • Minimum inputs
  • Maximum inputs
  • Boundary values
  • Special cases
6

Review Student View

Check that:
  • Description is clear
  • Sample cases are helpful
  • Time limits are reasonable
  • Template code works (if provided)

Sample Problems from Source

Wecode installation may include sample problems. To explore:
  1. Navigate to Problems list
  2. Look for problems marked “sharable”
  3. View problem details to see:
    • Test case structure
    • Description format
    • Language configuration
    • Template usage
  4. Export and study the structure
  5. Use as templates for your own problems

Advanced Features

Problem Import/Export

Exporting Problems:
1

Select Problems

Check boxes next to problems to export
2

Click Export

Download ZIP containing all problem data
3

Share or Archive

Use the ZIP for:
  • Sharing with other instructors
  • Backing up problem sets
  • Migrating to another Wecode instance
Importing Problems:
1

Prepare ZIP

Use exported ZIP or create in Wecode format
2

Navigate to Import

Problems → Import
3

Upload ZIP

Select your ZIP file
4

Review Results

Check which problems imported successfully

Problem Metadata

The export ZIP includes problem.wecode.metadata.json:
{
  "name": "Problem Name",
  "diff_cmd": "diff",
  "diff_arg": "-w",
  "allow_practice": true,
  "sharable": true,
  "difficult": "Medium",
  "author": "Dr. Smith",
  "languages": [
    {
      "name": "C++",
      "time_limit": 1.0,
      "memory_limit": 256
    }
  ],
  "tags": [
    {"text": "sorting"},
    {"text": "arrays"}
  ]
}
This metadata is used during import to recreate the problem. Provide solution explanations:
  1. Edit problem
  2. Enter URL in “Editorial” field
  3. Students see “View Editorial” link after submission
  4. Use for:
    • Detailed solution walkthroughs
    • Algorithm explanations
    • Video tutorials

Troubleshooting

Students Get Wrong Answer on Correct Code

Check:
  • Output format exactly matches expected
  • No extra spaces or newlines
  • Correct number of decimal places
  • Test cases are correct
Fix:
  • Review output files
  • Use diff -w to ignore whitespace if appropriate
  • Add sample test case that matches

All Submissions Get Compilation Error

Check:
  • Language is properly configured
  • Compiler is available on server
  • Template code compiles
  • File permissions on problem directory
Fix:
  • Test compilation manually on server
  • Check tester configuration
  • Verify problem directory permissions

Time Limit Too Strict

Symptoms: Correct solutions get TLE Fix:
  1. Verify with your own solution
  2. Increase time limit by 50-100%
  3. Rejudge all submissions
  4. Consider language-specific limits

Test Cases Not Found

Symptoms: All submissions fail with error Check:
  • Files are named correctly: input1.txt, output1.txt
  • Files are in correct directories: in/ and out/
  • Permissions allow web server to read files
  • Sequential numbering with no gaps
Fix:
  • Re-upload test cases
  • Verify file names (case-sensitive)
  • Check file permissions (644 for files, 755 for directories)

Summary

Creating problems in Wecode involves:
  • ✅ Defining problem metadata and settings
  • ✅ Writing clear, unambiguous descriptions
  • ✅ Creating comprehensive test cases
  • ✅ Configuring language support and limits
  • ✅ Optionally providing template code
  • ✅ Setting appropriate diff commands
  • ✅ Testing thoroughly before assignment
  • ✅ Maintaining and updating as needed
Key files in problem directory:
  • in/inputN.txt - Input test cases
  • out/outputN.txt - Expected outputs
  • desc.html - Problem description
  • problem.pdf - Optional PDF description
  • template.{ext} - Optional starter code
For adding problems to assignments, see the Instructor Guide. For system-level problem management, see the Admin Guide.

Build docs developers (and LLMs) love