Update APPS
Browse files
app.py
CHANGED
|
@@ -14,24 +14,35 @@ st.title("Code:blue[Arena]")
|
|
| 14 |
with st.spinner("Loading data...", show_time=True):
|
| 15 |
problem_dict = dict()
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
-
for problem in
|
| 20 |
problem_id = problem["title"]
|
| 21 |
problem['type'] = "leetcode"
|
| 22 |
problem_dict[problem_id] = problem
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
problem_count = len(problem_dict)
|
| 25 |
|
| 26 |
|
| 27 |
if "problem" in st.query_params:
|
| 28 |
problem_id = str(st.query_params["problem"])
|
|
|
|
| 29 |
problem_instance = problem_dict[problem_id]
|
| 30 |
|
| 31 |
st.header(problem_id)
|
| 32 |
|
| 33 |
with st.expander("Problem Description"):
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
with st.expander("Test Cases"):
|
| 37 |
test_cases = json.loads(problem_instance["test_cases"])
|
|
@@ -51,10 +62,13 @@ if "problem" in st.query_params:
|
|
| 51 |
)
|
| 52 |
|
| 53 |
with st.expander("Test Case Generator"):
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
|
| 60 |
else:
|
|
|
|
| 14 |
with st.spinner("Loading data...", show_time=True):
|
| 15 |
problem_dict = dict()
|
| 16 |
|
| 17 |
+
# Venus Data
|
| 18 |
+
venus_ds = load_dataset("Elfsong/leetcode_data", split='train')
|
| 19 |
+
for problem in venus_ds:
|
| 20 |
problem_id = problem["title"]
|
| 21 |
problem['type'] = "leetcode"
|
| 22 |
problem_dict[problem_id] = problem
|
| 23 |
+
|
| 24 |
+
# APPS Data
|
| 25 |
+
apps_ds = load_dataset("Elfsong/APPS_Python", split='test')
|
| 26 |
+
for problem in apps_ds:
|
| 27 |
+
problem_id = f'apps_{problem["problem_id"]}'
|
| 28 |
+
problem['type'] = "apps"
|
| 29 |
+
problem_dict[problem_id] = problem
|
| 30 |
|
| 31 |
problem_count = len(problem_dict)
|
| 32 |
|
| 33 |
|
| 34 |
if "problem" in st.query_params:
|
| 35 |
problem_id = str(st.query_params["problem"])
|
| 36 |
+
problem_type = problem['type']
|
| 37 |
problem_instance = problem_dict[problem_id]
|
| 38 |
|
| 39 |
st.header(problem_id)
|
| 40 |
|
| 41 |
with st.expander("Problem Description"):
|
| 42 |
+
if problem_type == "leetcode":
|
| 43 |
+
st.markdown(problem_instance["question_content"])
|
| 44 |
+
elif problem_type == "apps":
|
| 45 |
+
st.markdown(problem_instance["problem_content"])
|
| 46 |
|
| 47 |
with st.expander("Test Cases"):
|
| 48 |
test_cases = json.loads(problem_instance["test_cases"])
|
|
|
|
| 62 |
)
|
| 63 |
|
| 64 |
with st.expander("Test Case Generator"):
|
| 65 |
+
if problem_type == "leetcode":
|
| 66 |
+
test_case_generator = problem_instance["test_case_generator"]
|
| 67 |
+
prompt = "# For now, we only disclose the top 20 lines of the test case generator.\n# the full version will be released after the paper review process.\n"
|
| 68 |
+
test_case_generator = "\n".join(test_case_generator.split("\n")[:20])
|
| 69 |
+
st.code(prompt+test_case_generator)
|
| 70 |
+
else:
|
| 71 |
+
st.code("Stay tuned!")
|
| 72 |
|
| 73 |
|
| 74 |
else:
|