Spaces:
Sleeping
Sleeping
| """ | |
| Go Algorithms Dataset Loader | |
| Creates test data for Go algorithm evaluation. | |
| """ | |
| import os | |
| import json | |
| from typing import List, Dict, Any | |
| def create_test_data(data_path: str = "go_algorithms_test_data.json"): | |
| """Create test data for Go algorithm evaluation.""" | |
| test_data = { | |
| "sort_slice": { | |
| "input": [64, 34, 25, 12, 22, 11, 90], | |
| "expected_output": [11, 12, 22, 25, 34, 64, 90] | |
| }, | |
| "binary_search": { | |
| "input": {"slice": [1, 3, 5, 7, 9, 11, 13, 15], "target": 7}, | |
| "expected_output": 3 | |
| }, | |
| "fibonacci": { | |
| "input": 10, | |
| "expected_output": 55 | |
| }, | |
| "two_sum": { | |
| "input": {"nums": [2, 7, 11, 15], "target": 9}, | |
| "expected_output": [0, 1] | |
| }, | |
| "http_handler": { | |
| "input": {"method": "GET", "path": "/user"}, | |
| "expected_output": {"status": 200, "content_type": "application/json"} | |
| }, | |
| "worker_pool": { | |
| "input": {"jobs": 5, "workers": 3}, | |
| "expected_output": {"processed": 5, "concurrent": True} | |
| } | |
| } | |
| with open(data_path, 'w') as f: | |
| json.dump(test_data, f, indent=2) | |
| print(f"Created test data: {data_path}") | |
| return data_path | |
| def load_test_data(data_path: str = "go_algorithms_test_data.json") -> Dict[str, Any]: | |
| """Load test data for evaluation.""" | |
| if not os.path.exists(data_path): | |
| create_test_data(data_path) | |
| with open(data_path, 'r') as f: | |
| return json.load(f) | |
| if __name__ == "__main__": | |
| create_test_data() | |