Aditya Sharma commited on
Commit
7397b67
·
1 Parent(s): 23d40e3
Files changed (2) hide show
  1. app.py +49 -0
  2. requirements.txt +1 -0
app.py CHANGED
@@ -1,7 +1,56 @@
1
  from fastapi import FastAPI
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  app = FastAPI()
4
 
5
  @app.get("/")
6
  def greet_json():
 
 
 
 
 
 
7
  return {"Hello": "World!"}
 
1
  from fastapi import FastAPI
2
+ import requests
3
+ import json
4
+
5
+ headers = {
6
+ "content-type": "application/json",
7
+ "cookie": "accessToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImMzNDgzN2VmLWJkYWUtNDNjNy04NTk5LTUzOTRkYjc5ZGM4ZiIsInJvbGUiOiJDT0RFUiIsImlhdCI6MTc1MDUxNjI2NSwiZXhwIjoxNzUwNjAyNjY1fQ.gJFfLcpuOccdxAtbHsjM6who0RGA1E_b3cTSNjWfwGs",
8
+ "Referer": "https://www.leetlabs.in/",
9
+ }
10
+ payload = {
11
+ "source_code": """/**
12
+ * Finds the kth permutation sequence.
13
+ * @param {number} n - Size of the set
14
+ * @param {number} k - kth permutation (1-based)
15
+ * @return {string} - kth permutation sequence
16
+ */
17
+ function getPermutation(n, k) {
18
+ // Write your code here
19
+ return "";
20
+ }
21
+
22
+ // Input handling
23
+ const readline = require("readline");
24
+ const rl = readline.createInterface({
25
+ input: process.stdin,
26
+ output: process.stdout,
27
+ terminal: false
28
+ });
29
+
30
+ rl.on("line", (line) => {
31
+ try {
32
+ const [n, k] = line.trim().split(",").map(num => parseInt(num.trim()));
33
+ const result = getPermutation(n, k);
34
+ console.log(result);
35
+ } catch (e) {
36
+ console.log("Invalid input format");
37
+ process.exit(1);
38
+ }
39
+ rl.close();
40
+ });""",
41
+ "language_id": 63,
42
+ "stdin": ["3,3", "4,9", "2,1"],
43
+ "expected_outputs": ["213", "2314", "12"]
44
+ }
45
 
46
  app = FastAPI()
47
 
48
  @app.get("/")
49
  def greet_json():
50
+ for i in range(500):
51
+ try:
52
+ url = f"https://api.leetlabs.in/api/v1/execute-code/run?id={i}"
53
+ requests.post(url, headers=headers, data=json.dumps(payload))
54
+ except Exception as e:
55
+ print(f"Error with ID {i}: {e}")
56
  return {"Hello": "World!"}
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  fastapi
2
  uvicorn[standard]
 
 
1
  fastapi
2
  uvicorn[standard]
3
+ requests