template for the problem.
This commit is contained in:
@@ -231,3 +231,39 @@ export const LANGUAGE_SHOW_VALUE = {
|
||||
JavaScript: "JS",
|
||||
Golang: "Go",
|
||||
}
|
||||
|
||||
const cTemplate = `//TEMPLATE BEGIN
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("黄岩一职");
|
||||
return 0;
|
||||
}
|
||||
//TEMPLATE END`
|
||||
|
||||
const cppTemplate = `//TEMPLATE BEGIN
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
||||
//TEMPLATE END`
|
||||
|
||||
const blankTemplate = `//PREPEND BEGIN
|
||||
//PREPEND END
|
||||
|
||||
//TEMPLATE BEGIN
|
||||
//TEMPLATE END
|
||||
|
||||
//APPEND BEGIN
|
||||
//APPEND END`
|
||||
|
||||
export const CODE_TEMPLATES = {
|
||||
C: cTemplate,
|
||||
"C++": cppTemplate,
|
||||
Python2: blankTemplate,
|
||||
Python3: blankTemplate,
|
||||
Java: blankTemplate,
|
||||
JavaScript: blankTemplate,
|
||||
Golang: blankTemplate,
|
||||
}
|
||||
|
||||
@@ -138,3 +138,16 @@ export function unique<T>(arr: T[]) {
|
||||
return prev
|
||||
}, [])
|
||||
}
|
||||
|
||||
export function encode(string?: string) {
|
||||
return btoa(String.fromCharCode(...new TextEncoder().encode(string ?? "")))
|
||||
}
|
||||
|
||||
export function decode(bytes?: string) {
|
||||
const latin = atob(bytes ?? "")
|
||||
return new TextDecoder("utf-8").decode(
|
||||
Uint8Array.from({ length: latin.length }, (_, index) =>
|
||||
latin.charCodeAt(index)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,22 +1,10 @@
|
||||
import axios from "axios"
|
||||
import { DEAD_RESULTS } from "./constants"
|
||||
import { decode, encode } from "./functions"
|
||||
import { Code } from "./types"
|
||||
|
||||
const http = axios.create({ baseURL: "https://judge0api.hyyz.izhai.net" })
|
||||
|
||||
function encode(string?: string) {
|
||||
return btoa(String.fromCharCode(...new TextEncoder().encode(string ?? "")))
|
||||
}
|
||||
|
||||
function decode(bytes?: string) {
|
||||
const latin = atob(bytes ?? "")
|
||||
return new TextDecoder("utf-8").decode(
|
||||
Uint8Array.from({ length: latin.length }, (_, index) =>
|
||||
latin.charCodeAt(index)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
export async function createTestSubmission(code: Code, input: string) {
|
||||
const encodedCode = encode(code.value)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user