File size: 973 Bytes
b1a9c80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import json
import os

def load_all_tasks() -> tuple:
    tasks = {"EASY": [], "MEDIUM": [], "HARD": []}
    tests = {}
    
    # Find tasks dir relative to this file, not cwd
    base_dir = os.path.dirname(os.path.abspath(__file__))  
    tasks_dir = os.path.join(base_dir, "tasks")
    
    for task_folder in os.listdir(tasks_dir):
        task_path = os.path.join(tasks_dir, task_folder)
        if not os.path.isdir(task_path):
            continue
        with open(os.path.join(task_path, "task.json")) as f:
            task = json.load(f)
        with open(os.path.join(task_path, "tests.json")) as f:
            test_data = json.load(f)
        difficulty = task["difficulty"]
        tasks[difficulty].append(task)
        tests[task["id"]] = {
            "baseline_time": task["baseline_time_ms"],
            "baseline_mem": task["baseline_mem_mib"],
            "cases": test_data["cases"]
        }
    return tasks, tests

TASKS, TESTS = load_all_tasks()