File size: 1,617 Bytes
23d40e3
7397b67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23d40e3
 
 
 
 
7397b67
 
 
 
 
 
23d40e3
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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()

@app.get("/")
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!"}