@jutge.org/toolkit 4.4.9 → 4.4.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +1 -0
  2. package/assets/prompts/funcs/creators/create-solution.tpl.txt +23 -0
  3. package/assets/prompts/funcs/creators/create-statement.tpl.txt +28 -0
  4. package/assets/prompts/funcs/creators/private-test-cases.tpl.txt +12 -0
  5. package/assets/prompts/funcs/creators/sample-test-cases.tpl.txt +16 -0
  6. package/assets/prompts/funcs/creators/sample.dt.tpl.txt +15 -0
  7. package/assets/prompts/funcs/examples/statement.tex +23 -0
  8. package/assets/prompts/funcs/proglangs/py.md +9 -0
  9. package/assets/prompts/io/examples/statement-coda.tex +7 -0
  10. package/assets/python/pyexec.py +9 -2
  11. package/dist/index.js +707 -467
  12. package/docs/getting-started-guide.md +1 -1
  13. package/docs/login.md +0 -1
  14. package/docs/problem-anatomy.md +1 -1
  15. package/docs/quiz-anatomy.md +367 -0
  16. package/package.json +14 -11
  17. package/toolkit/ask.ts +1 -1
  18. package/toolkit/dummies.ts +5 -4
  19. package/toolkit/generate.ts +83 -14
  20. package/toolkit/lint.ts +3 -4
  21. package/toolkit/make.ts +20 -23
  22. package/toolkit/quiz.ts +22 -14
  23. package/toolkit/share.ts +5 -4
  24. package/toolkit/submit.ts +4 -1
  25. /package/assets/prompts/{examples → funcs/examples}/statement-coda.tex +0 -0
  26. /package/assets/prompts/{creators → io/creators}/create-solution.tpl.txt +0 -0
  27. /package/assets/prompts/{creators → io/creators}/create-statement.tpl.txt +0 -0
  28. /package/assets/prompts/{creators → io/creators}/create-translation.tpl.txt +0 -0
  29. /package/assets/prompts/{creators → io/creators}/private-test-cases.txt +0 -0
  30. /package/assets/prompts/{creators → io/creators}/sample-test-cases.txt +0 -0
  31. /package/assets/prompts/{examples → io/examples}/statement.tex +0 -0
  32. /package/assets/prompts/{generators → io/generators}/efficiency.md +0 -0
  33. /package/assets/prompts/{generators → io/generators}/hard.md +0 -0
  34. /package/assets/prompts/{generators → io/generators}/random.md +0 -0
  35. /package/assets/prompts/{proglangs → io/proglangs}/cc.md +0 -0
  36. /package/assets/prompts/{proglangs → io/proglangs}/py.md +0 -0
package/README.md CHANGED
@@ -110,6 +110,7 @@ For a complete walkthrough, see the [Getting Started Guide](docs/getting-started
110
110
 
111
111
  - **[Getting Started Guide](docs/getting-started-guide.md)** - Complete guide to using the toolkit
112
112
  - **[Problem Anatomy](docs/problem-anatomy.md)** - Understanding problem structure and files
113
+ - **[Quiz Anatomy](docs/quiz-anatomy.md)** - Understanding quiz problems and question types
113
114
  - **[JutgeAI Features](docs/jutge-ai.md)** - Using AI to generate content
114
115
 
115
116
  ### Installation Guides
@@ -0,0 +1,23 @@
1
+ Now, write a solution in {{proglang}} to solve this problem.
2
+
3
+ Take these instructions into account:
4
+
5
+ - It must be written in an idiomatic way and only include relevant comments.
6
+
7
+ - The code must be efficient and handle all edge cases.
8
+
9
+ - The code should only write the required {{functions}} functions and any helper functions that are needed.
10
+
11
+ - The code should not execute any statement.
12
+
13
+ - The code should not define a main program or a main function.
14
+
15
+ - The code should not define global variables but may define global constants.
16
+
17
+ - The code must be well written and easy to understand to novices. It cannot use advanced constructs.
18
+
19
+ - The code does not have to check the preconditions stated in the problem statement.
20
+
21
+ - Do not use any non-standard libraries.
22
+
23
+ {{proglangPrompt}}
@@ -0,0 +1,28 @@
1
+ You are to write the statement of a new {{proglang}} programming problem in {{language}}.
2
+
3
+ The statement must be written in LaTeX, using a few predefined macros.
4
+ Use LaTeX math syntax for formulas and variables.
5
+ Use \lstinline macros for inline code snippets.
6
+ Use dollars for inline maths and use \[ and \] for display maths.
7
+ Do not add input/output test cases in the statement.
8
+ Separate paragraphs by a blank line and \medskip macro.
9
+
10
+ Write in the style of programming contests like the ACM ICPC or Jutge.org.
11
+
12
+ Here is an example for an unrelated problem in English, follow its structure and macros:
13
+
14
+ {{latexExample}}
15
+
16
+ The title for the new problem is:
17
+
18
+ {{title}}
19
+
20
+ The theme of the new problem is:
21
+
22
+ {{theme}}
23
+
24
+ The functions that are requested in the new problem are:
25
+
26
+ {{functions}}
27
+
28
+ The headers of the functions must be written in {{proglang}}.
@@ -0,0 +1,12 @@
1
+ Now, write a {{proglang}} program that serves to check the correctness and the efficiency of function {{function}}.
2
+
3
+ This program should be a sequence of print statements that call {{function}} with some inputs.
4
+
5
+ Some inputs should cover edge cases and some other inputs should be used to check the efficiency.
6
+
7
+ Do not include comments now.
8
+
9
+ Do not use loops.
10
+
11
+ Do not add any formatting, markdown or code fences.
12
+
@@ -0,0 +1,16 @@
1
+ Now, write a {{proglang}} program that serves as sample test cases of the {{functions}} functions.
2
+
3
+ This program should be a sequence of print statements that call each of the required functions
4
+ with some sample inputs.
5
+
6
+ Sample test cases must be written in {{proglang}} and follow the specification of the functions.
7
+
8
+ Sample test cases should be relatively small but cover interesting cases but not all edge cases.
9
+
10
+ If the problem statement features some examples, include them as part of the sample test cases.
11
+
12
+ Do not include comments now.
13
+
14
+ Separate the tests for each function with an empty line.
15
+
16
+ Do not add any formatting, markdown or code fences.
@@ -0,0 +1,15 @@
1
+ Now, write a Python doctest with the same inputs as in this test cases:
2
+
3
+ {{sampleTests}}
4
+
5
+ Do not include comments now.
6
+
7
+ Separate the tests for each function with an empty line.
8
+
9
+ Do not add any formatting, markdown or code fences. Do not output empty lines.
10
+
11
+ Output should follow the format of Python doctests. For instance:
12
+ >>> factorial(5)
13
+ 120
14
+ >>> factorial(0)
15
+ 1
@@ -0,0 +1,23 @@
1
+ \Problem{Primes everywhere}
2
+
3
+ \UsePython
4
+
5
+ \Statement
6
+
7
+ Carla is a young girl who loves math. She is interested in prime numbers and wants some functions to help her in her mathematical musitations.
8
+
9
+ \medskip
10
+
11
+ \begin{enumerate}
12
+
13
+ \item Write a function \lstinline|is_prime(n: int) -> bool| that returns True if $n$ is a prime number, and False otherwise.
14
+
15
+ \item Write a function \lstinline|next_prime(n: int) -> int| that returns the smallest prime number greater than $n$.
16
+
17
+ \item Write a function \lstinline|count_primes(a: int, b: int) -> int| that returns the number of prime numbers between $a$ and $b$ inclusive.
18
+
19
+ \end{enumerate}
20
+
21
+ All given values by Carla are non-negative integers.
22
+
23
+ \SampleSession
@@ -0,0 +1,9 @@
1
+ # Additional guidelines for Python
2
+
3
+ - Use f-strings for string formatting when possible.
4
+
5
+ - Use type hints for function definitions. Do not use old-style type hints such as `List[int]` with `List` imported from `typing`, but use modern syntax such as `list[int]`.
6
+
7
+ - Ensure that the generated Python3 code follows best practices, including proper indentation, use of functions, use of docstrings, and adherence to PEP 8 style guidelines.
8
+
9
+ - Each function should be documented with a docstring.
@@ -0,0 +1,7 @@
1
+
2
+ \Observation
3
+
4
+ This problem has been generated by Jutge$^{\text{AI}}$. Remove this observation after reviewing it carefully.
5
+
6
+ \Sample
7
+
@@ -1,19 +1,26 @@
1
1
  # type: ignore
2
2
 
3
3
  """
4
- Execute some Python code given from stdin
4
+ Execute some Python code given from stdin and seed random number generator with argv[1].
5
5
  and print all resulting global variables as JSON.
6
6
  """
7
7
 
8
8
  import json
9
9
  import sys
10
10
  import types
11
+ import random
11
12
 
12
13
  # Read the code from stdin
13
14
  code = sys.stdin.read()
14
15
 
16
+ # Seed random number generator
17
+ seed = int(sys.argv[1])
18
+ random.seed(seed)
19
+
15
20
  # Create a namespace for execution
16
- namespace = {}
21
+ namespace = {
22
+ 'seed': seed # this makes sure that some variables are always present
23
+ }
17
24
 
18
25
  # Execute the code in the namespace
19
26
  exec(code, namespace)