Spaces:
Running
Running
from fastapi import FastAPI | |
import requests | |
import json | |
headers = { | |
"content-type": "application/json", | |
"cookie": "accessToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImMzNDgzN2VmLWJkYWUtNDNjNy04NTk5LTUzOTRkYjc5ZGM4ZiIsInJvbGUiOiJDT0RFUiIsImlhdCI6MTc1MDUxNjI2NSwiZXhwIjoxNzUwNjAyNjY1fQ.gJFfLcpuOccdxAtbHsjM6who0RGA1E_b3cTSNjWfwGs", | |
"Referer": "https://www.leetlabs.in/", | |
} | |
payload = { | |
"source_code": """/** | |
* Finds the kth permutation sequence. | |
* @param {number} n - Size of the set | |
* @param {number} k - kth permutation (1-based) | |
* @return {string} - kth permutation sequence | |
*/ | |
function getPermutation(n, k) { | |
// Write your code here | |
return ""; | |
} | |
// Input handling | |
const readline = require("readline"); | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
terminal: false | |
}); | |
rl.on("line", (line) => { | |
try { | |
const [n, k] = line.trim().split(",").map(num => parseInt(num.trim())); | |
const result = getPermutation(n, k); | |
console.log(result); | |
} catch (e) { | |
console.log("Invalid input format"); | |
process.exit(1); | |
} | |
rl.close(); | |
});""", | |
"language_id": 63, | |
"stdin": ["3,3", "4,9", "2,1"], | |
"expected_outputs": ["213", "2314", "12"] | |
} | |
app = FastAPI() | |
def greet_json(): | |
for i in range(500): | |
try: | |
url = f"https://api.leetlabs.in/api/v1/execute-code/run?id={i}" | |
requests.post(url, headers=headers, data=json.dumps(payload)) | |
except Exception as e: | |
print(f"Error with ID {i}: {e}") | |
return {"Hello": "World!"} |