Problem Creation Overview
A Wecode problem consists of:- Metadata: Name, author, difficulty, settings
- Description: Problem statement (HTML, Markdown, or PDF)
- Test Cases: Input/output pairs for judging
- Language Configuration: Supported languages with time/memory limits
- Template Code (optional): Starter code for students
- 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
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)
Configure Diff Command
Set how output is compared:
- diff_cmd: Command used for comparison
diff: Default, compares text exactlydiff -w: Ignores whitespace differencesdiff -b: Ignores blank line differences- Custom comparison script
- diff_arg: Additional arguments
-u: Unified diff format-i: Ignore case-B: Ignore blank lines
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
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
Add Tags
Categorize your problem with tags:
- Algorithm types (sorting, graph, dynamic programming)
- Data structures (array, tree, hash table)
- Difficulty indicators
- Course topics
After Creation
Once created, you must:- Add test cases
- Write problem description
- Optionally add template code
- Test the problem yourself
Test Case Structure
Test cases determine whether student submissions are correct.Directory Structure
Problems are stored inassignments_root/problems/{problem_id}/:
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
Example Test Cases
For a simple “Add Two Numbers” problem: in/input1.txt:Test Case Best Practices
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)
Test Different Scenarios
- Normal cases (typical inputs)
- Edge cases (boundaries)
- Corner cases (unusual combinations)
- Stress tests (large inputs)
Ensure Correctness
- Verify output format exactly
- Include newlines where required
- Check trailing spaces/newlines
- Test with sample solution
Uploading Test Cases
Wecode provides two methods for uploading test cases:Method 1: Upload Directory
Upload multiple files at once: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
Method 2: Upload ZIP File
Upload all test cases as a ZIP archive:Upload ZIP
- Choose the ZIP file in “Upload Tests (ZIP)” section
- Optionally check “Rename files” to auto-number them
- Click “Update Problem”
ZIP Auto-Rename Feature
When uploading a ZIP with “Rename files” checked:- Files in
/in/are renamed toinput1.txt,input2.txt, … - Files in
/out/are renamed tooutput1.txt,output2.txt, … - Files are numbered based on alphabetical order
- Useful when importing from external sources
Problem Descriptions
The problem description explains what students need to solve.Description Formats
Wecode supports three formats:- HTML (
desc.html): Rich formatting in browser - PDF (
problem.pdf): Standalone document - Both: HTML for quick view, PDF for download
Writing HTML Descriptions
Structure of desc.html:Editing Descriptions in Wecode
Write HTML
Use the HTML editor to write your description:
- Use toolbar for formatting
- Include sample inputs/outputs
- Specify constraints clearly
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
- Edit the problem
- In the ZIP upload or directory upload, include
problem.pdf - 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
Precise Input Format
- Specify number of lines
- Describe each line’s content
- Mention separators (spaces, newlines)
- Give ranges and constraints
Exact Output Format
- Specify precision for floating point
- Describe separators
- Mention newlines
- Show exact format
Include Examples
- Provide 2-3 sample inputs/outputs
- Explain the sample cases
- Show edge cases if helpful
Diff Command Configuration
Thediff_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
- 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
- Extra blank lines are acceptable
Case Insensitive
diff_cmd:diff
diff_arg: -i
Ignores:
- Upper vs lowercase
- 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
For problems requiring custom judging (e.g., floating point tolerance, multiple correct answers):- Write a comparison script in
tester_path/ - Set diff_cmd to your script name
- 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
- 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
- Solve the problem yourself
- Measure execution time
- Multiply by 2-3× for student solutions
- 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)
- Calculate theoretical memory needs
- Arrays:
elements × size_per_element - Example:
int array[1000000]= 4 MB
- Arrays:
- Add overhead for runtime, stack, etc.
- 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
- Time limit: 2-3× C++ time
- Memory limit: 2× C++ memory
- JVM overhead, slower startup
- Time limit: 3-5× C++ time
- Memory limit: 1.5-2× C++ memory
- Interpreted, slower execution
- 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- Ctemplate.pyortemplate.py3- Pythontemplate.java- Javatemplate.pas- Pascal
Creating Template Code
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)
Template Format
Structure:Example Template: Function Implementation
template.cpp:Example Template: Banned Keywords
template.py: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
- 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:Test Wrong Solutions
Submit intentionally incorrect solutions to verify:
- Wrong answer detected
- Time limit enforced
- Memory limit enforced
Test Edge Cases
Verify your test cases cover:
- Minimum inputs
- Maximum inputs
- Boundary values
- Special cases
Sample Problems from Source
Wecode installation may include sample problems. To explore:- Navigate to Problems list
- Look for problems marked “sharable”
- View problem details to see:
- Test case structure
- Description format
- Language configuration
- Template usage
- Export and study the structure
- Use as templates for your own problems
Advanced Features
Problem Import/Export
Exporting Problems:
Importing Problems:
Problem Metadata
The export ZIP includesproblem.wecode.metadata.json:
Editorial Links
Provide solution explanations:- Edit problem
- Enter URL in “Editorial” field
- Students see “View Editorial” link after submission
- 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
- Review output files
- Use
diff -wto 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
- Test compilation manually on server
- Check tester configuration
- Verify problem directory permissions
Time Limit Too Strict
Symptoms: Correct solutions get TLE Fix:- Verify with your own solution
- Increase time limit by 50-100%
- Rejudge all submissions
- 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/andout/ - Permissions allow web server to read files
- Sequential numbering with no gaps
- 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
in/inputN.txt- Input test casesout/outputN.txt- Expected outputsdesc.html- Problem descriptionproblem.pdf- Optional PDF descriptiontemplate.{ext}- Optional starter code

