@jutge.org/toolkit 4.2.6 → 4.2.8

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 (31) hide show
  1. package/README.md +133 -3
  2. package/assets/latex/root-pdf.tpl.tex +29 -0
  3. package/assets/latex/root-text.tpl.tex +34 -0
  4. package/assets/problems/demo/demo.pbm/README.md +24 -0
  5. package/assets/problems/demo/demo.pbm/award.html +1 -0
  6. package/assets/problems/demo/demo.pbm/award.png +0 -0
  7. package/assets/problems/demo/demo.pbm/campanar.png +0 -0
  8. package/assets/problems/demo/demo.pbm/handler.yml +2 -0
  9. package/assets/problems/demo/demo.pbm/jutge.png +0 -0
  10. package/assets/problems/demo/demo.pbm/jutge.svg +27 -0
  11. package/assets/problems/demo/demo.pbm/problem.en.tex +276 -0
  12. package/assets/problems/demo/demo.pbm/problem.en.yml +3 -0
  13. package/assets/problems/demo/demo.pbm/sample-1.inp +1 -0
  14. package/assets/problems/demo/demo.pbm/sample-2.inp +1 -0
  15. package/assets/problems/demo/demo.pbm/solution.py +5 -0
  16. package/assets/sty/{judgeit.sty → jutge.sty} +20 -16
  17. package/dist/index.js +529 -545
  18. package/docs/getting-started-guide.md +27 -254
  19. package/docs/install-linux.md +107 -0
  20. package/docs/install-macos.md +111 -0
  21. package/docs/install-windows.md +99 -0
  22. package/docs/problem-anatomy.md +4 -0
  23. package/package.json +10 -4
  24. package/toolkit/ask.ts +1 -1
  25. package/toolkit/convert.ts +72 -0
  26. package/toolkit/index.ts +2 -0
  27. /package/assets/sty/{judgeit.ca.sty → jutge.ca.sty} +0 -0
  28. /package/assets/sty/{judgeit.de.sty → jutge.de.sty} +0 -0
  29. /package/assets/sty/{judgeit.en.sty → jutge.en.sty} +0 -0
  30. /package/assets/sty/{judgeit.es.sty → jutge.es.sty} +0 -0
  31. /package/assets/sty/{judgeit.fr.sty → jutge.fr.sty} +0 -0
package/README.md CHANGED
@@ -1,5 +1,135 @@
1
- # new-jutge-toolkit
1
+ # Jutge Toolkit
2
2
 
3
- This repository contains a toolkit for creating and managing programming exercises on the Jutge.org platform.
3
+ A powerful command-line toolkit for creating and managing programming problems on the [Jutge.org](https://jutge.org) platform.
4
4
 
5
- This new repository is intended to replace the previous `jutge-toolkit` repository, providing enhanced features and improved usability for educators and developers.
5
+ ## Key Features
6
+
7
+ - 📝 Create new problems from scratch or using templates
8
+ - 🤖 Generate problems using JutgeAI
9
+ - 🔧 Compile and test solutions in multiple programming languages
10
+ - 📄 Generate PDF statements and other formats automatically
11
+ - ✅ Verify solutions against test cases
12
+ - ☁️ Upload and update problems directly to Jutge.org
13
+ - ✨ Beautiful terminal interface with color output and help
14
+
15
+ ## Installation
16
+
17
+ The toolkit requires [Bun](https://bun.sh) as a JavaScript runtime. Follow the installation guides for your platform:
18
+
19
+ - **[Linux Installation Guide](docs/linux-installation.md)**
20
+ - **[macOS Installation Guide](docs/macos-installation.md)**
21
+ - **[Windows Installation Guide](docs/windows-installation.md)**
22
+
23
+ ### Quick Install
24
+
25
+ If you already have Bun installed:
26
+
27
+ ```bash
28
+ bun install --global @jutge.org/toolkit
29
+ ```
30
+
31
+ Verify the installation:
32
+
33
+ ```bash
34
+ jtk --version
35
+ ```
36
+
37
+ ## Getting Started
38
+
39
+ ### Quick Start
40
+
41
+ ```bash
42
+ # Get help
43
+ jtk
44
+ jtk --help
45
+
46
+ # Check system dependencies
47
+ jtk doctor
48
+
49
+ # Ask JutgeAI for help (requires API key setup)
50
+ jtk ask "How do I create a problem?"
51
+
52
+ # Clone a template problem interactively
53
+ jtk clone
54
+
55
+ # Generate a new problem with AI
56
+ jtk generate problem
57
+
58
+ # Build problem files
59
+ cd my-problem.pbm
60
+ jtk make
61
+
62
+ # Verify a solution
63
+ jtk verify solution.py
64
+
65
+ # Upload to Jutge.org
66
+ jtk upload
67
+ ```
68
+
69
+ For a complete walkthrough, see the [Getting Started Guide](docs/getting-started-guide.md).
70
+
71
+ ## Documentation
72
+
73
+ ### Essential Guides
74
+
75
+ - **[Getting Started Guide](docs/getting-started-guide.md)** - Complete guide to using the toolkit
76
+ - **[Problem Anatomy](docs/problem-anatomy.md)** - Understanding problem structure and files
77
+ - **[JutgeAI Features](docs/jutge-ai.md)** - Using AI to generate content
78
+
79
+ ### Installation Guides
80
+
81
+ - **[Linux Installation](docs/linux-installation.md)** - Installation steps for Linux
82
+ - **[macOS Installation](docs/macos-installation.md)** - Installation steps for macOS
83
+ - **[Windows Installation](docs/windows-installation.md)** - Installation steps for Windows
84
+
85
+ ## Common Commands
86
+
87
+ ```bash
88
+ # Configuration
89
+ jtk config show # View current configuration
90
+ jtk config set <key> <value> # Set a configuration value
91
+ jtk config edit # Edit configuration file
92
+
93
+ # Problem Creation
94
+ jtk clone [template] # Clone a template problem
95
+ jtk generate problem # Generate problem with AI
96
+ jtk generate translations en es ca # Add statement translations
97
+ jtk generate solutions python cpp # Generate solutions in other languages
98
+
99
+ # Building and Testing
100
+ jtk make # Build all problem elements
101
+ jtk make pdf # Generate PDF statements only
102
+ jtk verify <program> # Test a solution
103
+ jtk clean # Clean temporary files
104
+
105
+ # Publishing
106
+ jtk upload # Upload problem to Jutge.org
107
+
108
+ # Maintenance
109
+ jtk upgrade # Update to latest version
110
+ jtk doctor # Check system dependencies
111
+ jtk about # Show toolkit information
112
+ ```
113
+
114
+ ## Requirements
115
+
116
+ ### Core Requirements
117
+ - [Bun](https://bun.sh) - JavaScript runtime (required)
118
+
119
+ ### Optional Dependencies
120
+ - **LaTeX** (for PDF generation) - texlive-xetex, texlive-fonts-recommended
121
+ - **Pandoc** (for format conversion)
122
+ - **Programming language compilers/interpreters** - Python, GCC/G++, Java, etc. (depending on your needs)
123
+
124
+ Run `jtk doctor` to check which dependencies are installed on your system.
125
+
126
+ ## Support
127
+
128
+ - **Documentation:** Check the [docs](docs/) folder for detailed guides
129
+ - **Get Help:** Use `jtk ask "your question"` to get AI-powered assistance
130
+ - **Issues:** Report bugs and feature requests on [GitHub Issues](https://github.com/jutge-org/jutge-toolkit/issues)
131
+ - **Community:** Visit [Jutge.org](https://jutge.org) for the problem platform
132
+
133
+ ## License
134
+
135
+ Copyright © Jutge.org. All rights reserved.
@@ -0,0 +1,29 @@
1
+ \documentclass[11pt]{article}
2
+
3
+ \usepackage{jutge}
4
+ \usepackage{{curly jutgeLanguage}}
5
+
6
+ \begin{document}
7
+
8
+ \providecommand{\SampleOneCol}{{curly samples1c}}
9
+ \providecommand{\SampleTwoCol}{{curly samples2c}}
10
+
11
+ \ProblemId{{curly id}}
12
+
13
+ \DoProblem{{curly language}}
14
+
15
+ \ProblemInformation
16
+
17
+ \Author: {{author}}
18
+
19
+ {{#if translator}}
20
+ {{language}}: {{translator}}
21
+ {{/if}}
22
+
23
+ \Generation: {{date}}
24
+
25
+ \subsection*{Draft}
26
+
27
+ Draft generated with \textbf{new-jutge-toolkit}.
28
+
29
+ \end{document}
@@ -0,0 +1,34 @@
1
+
2
+ \documentclass[11pt]{article}
3
+
4
+ \usepackage{jutge}
5
+ \usepackage{{curly jutgeLanguage}}
6
+
7
+ % redefine commands to simplify text output
8
+ \renewcommand{\Sample}{}
9
+ \renewcommand{\Statement}{}
10
+ \renewcommand{\Problem}[1]{\section{#1}}
11
+ \ProblemId{{curly id}}
12
+
13
+ % redefine figure commands to avoid troubles with \parpic
14
+ \renewcommand{\FigureL}[2]{\includegraphics[#1]{#2}}
15
+ \renewcommand{\FigureC}[2]{\includegraphics[#1]{#2}}
16
+ \renewcommand{\FigureR}[2]{\includegraphics[#1]{#2}}
17
+
18
+ \begin{document}
19
+
20
+ \DoProblem{{curly language}}
21
+
22
+
23
+ \subsection*{\TxtAuthor}
24
+ {{author}}
25
+
26
+ {{#if translator}}
27
+ {{language}}: {{translator}}
28
+ {{/if}}
29
+
30
+ \subsection*{Draft}
31
+
32
+ Draft generated with \textbf{new-jutge-toolkit}.
33
+
34
+ \end{document}
@@ -0,0 +1,24 @@
1
+ # Demo Problem
2
+
3
+ ## Features
4
+
5
+ - Text formatting
6
+ - Special characters
7
+ - Mathematical expressions
8
+ - Conditional rendering
9
+ - Images
10
+ - Code snippets
11
+ - Inline code
12
+ - Colors
13
+ - PS Tricks
14
+ - Tikz
15
+ - Chessboards
16
+ - Sectioning macros
17
+ - Programming language configurations
18
+ - Interface descriptions
19
+ - Scoring descriptions
20
+ - Sample input/output macros
21
+
22
+ ## Abstract
23
+
24
+ This document is a comprehensive guide to creating problem statements for Jutge.org using LaTeX, covering text formatting, mathematical expressions, code snippets, images, and various specialized features that render across multiple output formats (PDF, HTML, Markdown, and plain text).
@@ -0,0 +1 @@
1
+ <p>Problem solved, congratulations!</p>
@@ -0,0 +1,2 @@
1
+ handler: std
2
+ solution: Python3
@@ -0,0 +1,27 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg viewBox="0 0 49 66" version="1.1" xmlns="http://www.w3.org/2000/svg">
4
+ <path fill="#ffffff" d=" M 0.00 0.00 L 49.00 0.00 L 49.00 66.00 L 0.00 66.00 L 0.00 0.00 Z" />
5
+ <path fill="#464847" d=" M 5.72 8.49 C 6.65 5.88 9.84 6.49 12.00 6.32 C 21.01 6.50 30.02 6.34 39.03 6.32 C 40.76 6.13 42.43 6.94 43.21 8.52 C 43.99 11.55 43.27 14.84 44.11 17.80 C 45.49 18.74 47.21 19.77 47.28 21.66 C 47.57 23.41 46.00 24.67 45.21 26.06 C 47.18 27.64 47.91 30.03 46.63 32.31 C 46.71 31.15 46.79 29.98 46.88 28.82 C 46.14 27.92 45.41 27.03 44.68 26.13 C 44.04 26.10 42.76 26.05 42.12 26.03 C 41.49 27.57 40.06 29.17 40.86 30.92 C 41.39 33.00 43.85 33.12 45.45 33.98 C 44.55 33.82 42.74 33.51 41.84 33.35 C 40.04 31.03 40.09 28.17 41.84 25.81 C 40.26 23.77 40.33 21.30 40.77 18.88 C 37.72 17.01 34.77 14.89 32.72 11.90 C 34.54 13.79 36.46 15.59 38.56 17.17 C 39.93 17.96 41.47 19.42 42.88 17.84 C 44.24 15.47 43.16 12.61 43.11 10.05 C 43.20 7.96 41.25 6.85 39.46 6.48 C 32.48 6.54 25.50 6.63 18.53 6.68 C 16.37 6.61 14.21 6.55 12.05 6.54 C 10.13 6.74 7.87 6.51 6.32 7.86 C 5.39 11.06 5.70 14.45 5.52 17.74 C 6.58 18.46 7.64 19.17 8.70 19.89 C 11.13 19.27 13.57 18.66 15.98 17.96 C 19.12 16.97 22.25 15.98 25.32 14.78 C 27.32 13.94 29.27 12.98 31.18 11.95 C 24.53 16.43 16.45 17.90 8.88 20.13 C 8.62 22.91 8.08 25.75 5.00 26.90 C 9.37 25.00 8.70 30.27 7.98 32.56 C 5.46 33.78 1.28 34.45 2.18 38.30 C 2.42 38.75 2.90 39.67 3.13 40.12 C 0.60 38.45 1.82 35.18 3.71 33.63 C 0.39 30.62 4.11 26.38 1.94 23.02 C 0.97 20.66 3.26 18.57 5.20 17.67 C 5.41 14.61 5.20 11.52 5.72 8.49 Z" />
6
+ <path fill="#d5d5d5" d=" M 6.32 7.86 C 7.87 6.51 10.13 6.74 12.05 6.54 C 12.54 7.29 13.02 8.04 13.51 8.79 C 13.09 10.26 12.68 11.74 12.26 13.22 C 12.90 13.46 13.54 13.69 14.18 13.93 C 13.28 15.78 14.45 16.99 15.98 17.96 C 13.57 18.66 11.13 19.27 8.70 19.89 C 7.64 19.17 6.58 18.46 5.52 17.74 C 5.70 14.45 5.39 11.06 6.32 7.86 Z" />
7
+ <path fill="#e4e4e4" d=" M 12.05 6.54 C 14.21 6.55 16.37 6.61 18.53 6.68 C 20.09 7.21 21.63 7.79 23.17 8.36 C 22.89 9.77 22.61 11.18 22.33 12.59 C 23.32 13.32 24.32 14.05 25.32 14.78 C 22.25 15.98 19.12 16.97 15.98 17.96 C 14.45 16.99 13.28 15.78 14.18 13.93 C 13.54 13.69 12.90 13.46 12.26 13.22 C 12.68 11.74 13.09 10.26 13.51 8.79 C 13.02 8.04 12.54 7.29 12.05 6.54 Z" />
8
+ <path fill="#efefef" d=" M 18.53 6.68 C 25.50 6.63 32.48 6.54 39.46 6.48 C 39.93 10.07 39.67 13.70 38.56 17.17 C 36.46 15.59 34.54 13.79 32.72 11.90 C 32.59 11.75 32.34 11.45 32.22 11.31 C 31.96 11.47 31.44 11.79 31.18 11.95 C 29.27 12.98 27.32 13.94 25.32 14.78 C 24.32 14.05 23.32 13.32 22.33 12.59 C 22.61 11.18 22.89 9.77 23.17 8.36 C 21.63 7.79 20.09 7.21 18.53 6.68 Z" />
9
+ <path fill="#dcdcdc" d=" M 39.46 6.48 C 41.25 6.85 43.20 7.96 43.11 10.05 C 43.16 12.61 44.24 15.47 42.88 17.84 C 41.47 19.42 39.93 17.96 38.56 17.17 C 39.67 13.70 39.93 10.07 39.46 6.48 Z" />
10
+ <path fill="#eddccb" d=" M 31.18 11.95 C 31.44 11.79 31.96 11.47 32.22 11.31 C 32.34 11.45 32.59 11.75 32.72 11.90 C 34.77 14.89 37.72 17.01 40.77 18.88 C 40.33 21.30 40.26 23.77 41.84 25.81 C 40.09 28.17 40.04 31.03 41.84 33.35 C 41.41 33.73 40.56 34.50 40.13 34.88 C 39.32 37.93 41.17 40.39 43.38 42.23 C 43.19 44.60 42.88 47.27 40.80 48.81 C 34.15 49.95 27.38 48.20 20.72 49.27 C 16.63 49.71 12.51 49.40 8.41 49.50 C 6.00 47.26 4.74 44.15 5.12 40.82 C 6.22 40.66 7.32 40.50 8.41 40.28 C 8.40 38.61 8.51 36.93 8.45 35.26 C 8.33 34.59 8.09 33.23 7.98 32.56 C 8.70 30.27 9.37 25.00 5.00 26.90 C 8.08 25.75 8.62 22.91 8.88 20.13 C 16.45 17.90 24.53 16.43 31.18 11.95 Z" />
11
+ <path fill="#d7d7d7" d=" M 2.22 23.09 C 1.70 20.80 3.49 19.19 5.02 17.85 C 6.16 18.58 7.31 19.29 8.46 20.01 C 8.15 21.93 8.48 25.04 5.98 25.54 C 4.18 26.33 3.46 23.87 2.22 23.09 Z" />
12
+ <path fill="#d3d4d6" d=" M 45.25 25.74 C 40.12 27.53 38.76 18.01 44.07 18.46 C 47.42 19.29 47.41 23.62 45.25 25.74 Z" />
13
+ <path fill="#010402" d=" M 17.98 33.17 C 15.74 29.78 14.92 23.82 18.91 21.44 C 21.17 24.83 21.95 30.76 17.98 33.17 Z" />
14
+ <path fill="#010203" d=" M 29.14 21.46 C 32.98 23.76 32.90 30.75 29.24 33.21 C 26.65 29.84 26.67 24.89 29.14 21.46 Z" />
15
+ <path fill="#d9d9d8" d=" M 42.12 26.03 C 42.76 26.05 44.04 26.10 44.68 26.13 C 45.41 27.03 46.14 27.92 46.88 28.82 C 46.79 29.98 46.71 31.15 46.63 32.31 C 46.58 33.00 46.56 33.69 46.51 34.38 C 46.13 36.60 47.07 40.17 44.00 40.64 C 40.91 40.56 40.88 37.08 40.13 34.88 C 40.56 34.50 41.41 33.73 41.84 33.35 C 42.74 33.51 44.55 33.82 45.45 33.98 C 43.85 33.12 41.39 33.00 40.86 30.92 C 40.06 29.17 41.49 27.57 42.12 26.03 Z" />
16
+ <path fill="#dbdbdb" d=" M 2.80 28.85 C 3.51 26.64 6.12 27.70 7.75 26.96 C 8.55 29.07 8.65 32.43 5.96 33.15 C 3.43 34.66 1.97 30.77 2.80 28.85 Z" />
17
+ <path fill="#d2d7da" d=" M 2.18 38.30 C 1.28 34.45 5.46 33.78 7.98 32.56 C 8.09 33.23 8.33 34.59 8.45 35.26 C 8.27 36.63 8.19 38.01 8.07 39.39 C 6.69 39.84 5.29 40.32 3.82 40.21 L 3.13 40.12 C 2.90 39.67 2.42 38.75 2.18 38.30 Z" />
18
+ <path fill="#010100" d=" M 8.07 39.39 C 8.19 38.01 8.27 36.63 8.45 35.26 C 8.51 36.93 8.40 38.61 8.41 40.28 C 7.32 40.50 6.22 40.66 5.12 40.82 C 4.74 44.15 6.00 47.26 8.41 49.50 C 12.51 49.40 16.63 49.71 20.72 49.27 L 20.54 50.18 C 20.62 51.20 20.78 53.23 20.86 54.25 C 20.73 54.37 20.47 54.60 20.33 54.71 C 20.23 53.25 20.10 51.79 19.94 50.34 L 19.86 49.75 C 17.08 49.84 14.34 50.37 11.67 51.13 C 10.64 55.18 10.12 60.32 13.94 63.11 C 10.65 63.03 7.36 63.03 4.07 63.23 C 4.50 59.08 5.38 54.97 5.25 50.78 C 6.59 47.65 4.40 44.24 4.75 40.92 C 4.35 40.72 3.54 40.32 3.13 40.12 L 3.82 40.21 C 5.29 40.32 6.69 39.84 8.07 39.39 Z" />
19
+ <path fill="#ada093" d=" M 40.13 34.88 C 40.88 37.08 40.91 40.56 44.00 40.64 C 47.07 40.17 46.13 36.60 46.51 34.38 C 48.63 37.10 47.01 40.23 44.25 41.58 C 44.13 44.42 43.59 47.22 42.21 49.73 C 39.66 49.59 37.11 49.56 34.57 49.57 C 32.54 49.55 30.51 49.67 28.49 49.78 L 27.71 49.81 C 25.32 49.95 22.93 50.08 20.54 50.18 L 20.72 49.27 C 27.38 48.20 34.15 49.95 40.80 48.81 C 42.88 47.27 43.19 44.60 43.38 42.23 C 41.17 40.39 39.32 37.93 40.13 34.88 Z" />
20
+ <path fill="#010100" d=" M 14.82 39.58 C 20.72 42.70 27.94 42.40 34.04 39.98 C 29.44 45.66 19.14 45.53 14.82 39.58 Z" />
21
+ <path fill="#fcfbfa" d=" M 8.31 46.79 C 14.53 46.25 20.78 46.66 27.02 46.57 C 31.59 46.66 36.21 46.11 40.73 46.98 C 38.81 48.56 36.23 48.11 33.93 48.17 C 26.97 48.01 20.01 48.13 13.05 48.15 C 11.49 47.85 9.06 48.72 8.31 46.79 Z" />
22
+ <path fill="#242424" d=" M 11.67 51.13 C 14.34 50.37 17.08 49.84 19.86 49.75 L 19.94 50.34 C 18.51 50.73 16.95 50.86 15.66 51.64 C 15.11 55.44 14.34 60.00 17.09 63.17 C 16.31 63.15 14.73 63.13 13.94 63.11 C 10.12 60.32 10.64 55.18 11.67 51.13 Z" />
23
+ <path fill="#fefefe" d=" M 20.54 50.18 C 22.93 50.08 25.32 49.95 27.71 49.81 C 27.92 54.50 29.55 58.90 31.07 63.28 C 26.70 63.47 22.33 63.45 17.96 63.25 C 18.77 60.41 19.69 57.60 20.33 54.71 C 20.47 54.60 20.73 54.37 20.86 54.25 C 20.78 53.23 20.62 51.20 20.54 50.18 Z" />
24
+ <path fill="#464847" d=" M 27.71 49.81 L 28.49 49.78 C 30.20 50.31 31.87 50.92 33.55 51.52 C 34.86 55.45 34.59 59.62 32.25 63.10 C 32.87 63.08 34.10 63.03 34.72 63.00 C 38.13 62.98 41.53 62.99 44.94 63.19 C 31.34 63.76 17.68 63.61 4.07 63.23 C 7.36 63.03 10.65 63.03 13.94 63.11 C 14.73 63.13 16.31 63.15 17.09 63.17 C 14.34 60.00 15.11 55.44 15.66 51.64 C 16.95 50.86 18.51 50.73 19.94 50.34 C 20.10 51.79 20.23 53.25 20.33 54.71 C 19.69 57.60 18.77 60.41 17.96 63.25 C 22.33 63.45 26.70 63.47 31.07 63.28 C 29.55 58.90 27.92 54.50 27.71 49.81 Z" />
25
+ <path fill="#212121" d=" M 28.49 49.78 C 30.51 49.67 32.54 49.55 34.57 49.57 C 35.77 50.19 36.95 50.85 38.14 51.51 C 37.76 54.84 37.55 58.19 37.49 61.54 C 36.57 62.04 35.65 62.53 34.72 63.00 C 34.10 63.03 32.87 63.08 32.25 63.10 C 34.59 59.62 34.86 55.45 33.55 51.52 C 31.87 50.92 30.20 50.31 28.49 49.78 Z" />
26
+ <path fill="#010202" d=" M 34.57 49.57 C 37.11 49.56 39.66 49.59 42.21 49.73 L 43.50 49.80 C 43.39 54.31 44.30 58.75 44.94 63.19 C 41.53 62.99 38.13 62.98 34.72 63.00 C 35.65 62.53 36.57 62.04 37.49 61.54 C 37.55 58.19 37.76 54.84 38.14 51.51 C 36.95 50.85 35.77 50.19 34.57 49.57 Z" />
27
+ </svg>
@@ -0,0 +1,276 @@
1
+ \Problem{Demo Problem}
2
+
3
+ \Statement
4
+
5
+ \paragraph{Abstract.}
6
+
7
+ This a demo problem whose statement includes many elements that can be used in Jutge.org.
8
+ Please refer to its source code to see how to include these elements in your own problem statements.
9
+
10
+ \medskip
11
+
12
+ Problems statements are written in \LaTeX, which allows for great flexibility and high-quality typesetting.
13
+ Resulting statements are rendered in PDF, HTML, Markdown, and plain Text formats. Jutge.org aims to have
14
+ a consistent appearance across all formats, although some features may vary depending on the capabilities of each format.
15
+
16
+
17
+ \paragraph{Text.}
18
+
19
+ Regular text is just written as \LaTeX.
20
+ It is important to remember to separate paragraphs with the \verb|\medskip| macro.
21
+
22
+ \medskip
23
+
24
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum vestibulum.
25
+ Cras venenatis euismod malesuada.
26
+ Nullam ac erat ante.
27
+ Sed vel lacus id mauris dapibus facilisis.
28
+ Nam euismod, tortor nec pharetra ultricies, ante erat imperdiet velit, nec laoreet enim lacus a velit.
29
+
30
+ \medskip
31
+
32
+ Latin accents and special characters are supported out of the box: Bé, sí, allà algú dirà: «Què farà l'avió demà?» "Potser" vindrà ràpid, però demanarà atenció.
33
+ Greek letters works well: Καλημέρα, πώς είστε σήμερα.
34
+ Asiatic languages work well in HTML but not in PDF: 你好,很高兴认识你。「はじめまして、よろしくお願いします。」.
35
+ Emojis work well in HTML but not so-so in PDF: ⚠ 😀 .
36
+
37
+ \paragraph{Maths.}
38
+
39
+ The use of mathematical expressions is also supported.
40
+ They can be included inline, like the famous $E = mc^2$ formula or simply as $\sqrt x$, or as separate displayed equations.
41
+ For example, we can write the quadratic formula as follows:
42
+
43
+ \[
44
+ x = \frac{{-b \pm \sqrt{{b^2 - 4ac}}}}{{2a}}
45
+ \]
46
+
47
+ or express the Pythagorean theorem:
48
+
49
+ \[
50
+ a^2 + b^2 = c^2
51
+ \]
52
+
53
+ The rendering of these expressions will use MathML in the HTML version, ensuring very nice results.
54
+ In the Text and Markdown versions, mathematical expressions will be represented using some unicode symbols or in LaTeX format.
55
+
56
+
57
+ \paragraph{Conditional rendering.}
58
+
59
+ Some parts of the statement can be conditionally included depending on the output format.
60
+
61
+ \medskip
62
+
63
+ \begin{latexonly}
64
+ This text is only included in the PDF version of the statement.
65
+ \end{latexonly}
66
+
67
+ \begin{htmlonly}
68
+ This text is only included in the HTML, Markdown and Text versions of the statement.
69
+ \end{htmlonly}
70
+
71
+
72
+
73
+ \paragraph{Images.}
74
+
75
+ Images can also be included in the statement. For instance, here are two images of the famous bell tower of La Torrassa:
76
+
77
+ \begin{center}
78
+ \includegraphics[width=3cm]{campanar}
79
+ \qquad
80
+ \includegraphics[width=5cm]{campanar}
81
+ \end{center}
82
+
83
+ Available formats are PNG, JPG, PDF, BMP and EPS. SVG is also supported in HTML but not in PDF. Prefer vector formats (PDF, EPS, SVG) whenever possible to ensure the best quality at any size, and use PNG or JPG only for raster and photographic images.
84
+
85
+ \medskip
86
+
87
+ Use conditional rendering to include different images depending on the output format:
88
+
89
+ \begin{center}
90
+ \begin{latexonly}
91
+ \includegraphics[width=3cm]{jutge.png}
92
+ \end{latexonly}
93
+ \begin{htmlonly}
94
+ \includegraphics[width=3cm]{jutge.svg}
95
+ \end{htmlonly}
96
+ \end{center}
97
+
98
+ In the HTML version, figures will be embedded in the document, ensuring compatibility across different browsers without relying on external files. In the Text and Markdown versions of the statement, images will be represented by their filenames enclosed in square brackets. Unfortunately, Pandoc does not honor alignment of images.
99
+
100
+
101
+ \paragraph{Code.}
102
+
103
+ Code snippets can be included using the \textbf{listings} package. Here is a simple Python code example:
104
+
105
+ \begin{lstlisting}[language=Python, xleftmargin=0.75cm]
106
+ import yogi
107
+
108
+ a = yogi.read(int)
109
+ b = yogi.read(int)
110
+ print(a + b)
111
+ \end{lstlisting}
112
+
113
+ and here is a C++ code example:
114
+
115
+ \begin{lstlisting}[language=C++, xleftmargin=0.75cm]
116
+ #include <iostream>
117
+ using namespace std;
118
+
119
+ int main() {
120
+ int a, b;
121
+ cin >> a >> b;
122
+ cout << a + b << endl;
123
+ return 0;
124
+ }
125
+ \end{lstlisting}
126
+
127
+ The listings package supports many programming languages and produces nicely formatted code both in PDF and HTML statements.
128
+
129
+ \medskip
130
+
131
+ \lstset{language=C++}
132
+ Code snippets can also be included inline: \lstinline|if (found) cout << pos;|.
133
+ In this case, it was necessary to use \verb|\lstset{language=C++}| to set the language.
134
+
135
+
136
+ \paragraph{Inline code deprecations.}
137
+
138
+ The former use of at signs (@) and vertical bars (|) to include inline code snippets is deprecated because \textbf{pandoc} does not support it and introduced conflicts with other packages. You will have to replace them with \verb|\lstinline| or with \verb|\verb|| as shown above. Statements with at signs for inline listings can be automatically converted using \texttt{jtk convert transform-at-signs}.
139
+
140
+
141
+ \paragraph{Colors.}
142
+
143
+ Colors can be used in the statement using the \texttt{color} package.
144
+ For instance, \textcolor{red}{this text is red}, \textcolor{blue}{this text is blue}, and \textcolor{green}{this text is green}.
145
+ Of course, colors are not supported in the Text and Markdown versions of the statement.
146
+
147
+
148
+ \paragraph{PS Tricks.}
149
+
150
+ PS Tricks figures can also be included in the statement but this is discouraged as it is not supported in HTML. Here is a simple example:
151
+
152
+ \begin{center}
153
+ \begin{pspicture}(0,0)(2,2)
154
+ \psline{->}(0,0)(2,2)
155
+ \pscircle(1,1){1}
156
+ \end{pspicture}
157
+ \end{center}
158
+
159
+ \paragraph{Tikz.}
160
+
161
+ Tikz figures can also be included in the statement but this is discouraged as it is not supported in HTML. Here is a simple example:
162
+
163
+ \begin{center}
164
+ \begin{tikzpicture}
165
+ \draw[->] (0,0) -- (2,2);
166
+ \draw (1,1) circle (1cm);
167
+ \end{tikzpicture}
168
+ \end{center}
169
+
170
+ \paragraph{Chessboards.}
171
+
172
+ Chessboards can also be drawn in the statement using the \texttt{chessboard} package but this is discouraged as they are not supported in HTML.
173
+
174
+ \begin{center}
175
+ \chessboard[setpieces={Ke1, Qd1, Ra1, Rh1, Bc1, Bf1, Nb1, Ng1,
176
+ ke8, qd8, ra8, rh8, bc8, bf8, nb8, ng8},
177
+ showmover=false]
178
+ \end{center}
179
+
180
+
181
+
182
+ \Input
183
+
184
+ The Input section describes the format of the input data that your program will receive.
185
+
186
+ \Output
187
+
188
+ The Output section describes the format of the output data that your program must produce.
189
+
190
+ \Observation
191
+
192
+ There are a bunch of sectioning macros that can be used to include additional information in the statement:
193
+
194
+ \begin{itemize*}
195
+ \item \verb|\Observation|
196
+ \item \verb|\Observations|
197
+ \item \verb|\Example|
198
+ \item \verb|\Precondition|
199
+ \item \verb|\Scoring|
200
+ \item \verb|\Scores|
201
+ \item \verb|\Hint|
202
+ \item \verb|\Interface|
203
+ \item \verb|\ObservationElastic|
204
+ \item \verb|\ObservationElasticII|
205
+ \item \verb|\ObservationNoMain|
206
+ \item \verb|\Solution|
207
+ \end{itemize*}
208
+
209
+ These are localized automatically depending on the language of the problem.
210
+
211
+ \medskip
212
+
213
+ The following macros configure the listings package used to display code snippets according to the some programming languages:
214
+
215
+ \begin{itemize*}
216
+ \item \verb|\UseCPP|
217
+ \item \verb|\UsePython|
218
+ \item \verb|\UseHaskell|
219
+ \item \verb|\UseClojure|
220
+ \end{itemize*}
221
+
222
+
223
+ \medskip
224
+
225
+ Interface macros are provided to describe possible interfaces that depend on the programming language used (we plan to improve this in the future):
226
+
227
+ \Interface
228
+ \begin{tabular}{rl}
229
+ C++ &
230
+ \begin{lstlisting}[language=C++]
231
+ int factorial(int n);
232
+ \end{lstlisting}
233
+ \\
234
+ C &
235
+ \begin{lstlisting}[language=C]
236
+ int factorial(int n);
237
+ \end{lstlisting}
238
+ \\
239
+ Java &
240
+ \begin{lstlisting}[language=Java]
241
+ public static int factorial(int n);
242
+ \end{lstlisting}
243
+ \\
244
+ Python &
245
+ \begin{lstlisting}[language=Python]
246
+ factorial(n) # returns int
247
+ \end{lstlisting}
248
+ \\
249
+ &
250
+ \begin{lstlisting}[language=Python]
251
+ factorial(n: int) -> int
252
+ \end{lstlisting}
253
+ \end{tabular}
254
+
255
+ \bigskip
256
+
257
+ Scoring macros are provided to describe how the problem will be scored (you also need to provide a matching \texttt{scores.yml} file!):
258
+
259
+ \Scoring
260
+
261
+ \Score{Case A}{20}{Easy inputs.}
262
+ \Score{Case B}{30}{Medium inputs.}
263
+ \Score{Case C}{50}{Hard inputs.}
264
+
265
+
266
+ \medskip
267
+
268
+ Macros for including sample inputs and outputs are also provided:
269
+
270
+ \begin{itemize*}
271
+ \item \verb|\Sample|
272
+ \item \verb|\SampleOneCol|
273
+ \item \verb|\SampleTwoCol|
274
+ \item \verb|\SampleSession|
275
+ \end{itemize*}
276
+
@@ -0,0 +1,3 @@
1
+ author: Jordi Petit
2
+ email: jpetit@somewhere.com
3
+ title: Demo Problem
@@ -0,0 +1 @@
1
+ 15 27
@@ -0,0 +1,5 @@
1
+ import yogi
2
+
3
+ a = yogi.read(int)
4
+ b = yogi.read(int)
5
+ print(a + b)
@@ -17,33 +17,38 @@
17
17
  ItalicFont=texgyrecursor-italic.otf,
18
18
  BoldItalicFont=texgyrecursor-bolditalic.otf
19
19
  ]
20
+ \usepackage{unicode-math}
21
+ \setmainfont{texgyrepagella-regular.otf}[
22
+ BoldFont=texgyrepagella-bold.otf,
23
+ ItalicFont=texgyrepagella-italic.otf,
24
+ BoldItalicFont=texgyrepagella-bolditalic.otf
25
+ ]
26
+ \setmathfont{texgyrepagella-math.otf}
20
27
 
21
28
  %remove for xelatex
22
29
  %\usepackage{mathpazo}
23
30
  %\usepackage{helvet}
24
31
  %\usepackage{courier}
25
32
 
33
+ \usepackage{graphicx}
34
+ \usepackage{moreverb} % for verbatimtabinput
26
35
  \usepackage{mdwlist}
27
- \usepackage{shortvrb}
28
36
  \usepackage{picins}
29
37
  \usepackage{pstricks}
30
38
  \usepackage{pst-tree}
31
39
  \usepackage{graphicx}
32
40
  \usepackage{amsmath}
33
41
  \usepackage{geometry}
34
- \usepackage{moreverb}
35
42
  \usepackage{multicol}
36
43
  %\usepackage[utf8]{inputenc} %remove for xelatex
37
44
  \usepackage{listings}
38
45
  \usepackage{textcomp}
39
46
  \usepackage{chessboard}
40
47
  \usepackage{tikz}
41
- \usepackage{wasysym}
42
- \usepackage{eurosym}
48
+ %\usepackage{wasysym} % remove because not used
43
49
  \usepackage{color}
44
50
 
45
51
 
46
-
47
52
  \geometry{
48
53
  a4paper,twoside,
49
54
  left=2.75cm,right=2.75cm,
@@ -54,10 +59,6 @@
54
59
  \setlength{\parindent}{0cm}
55
60
  \pagestyle{empty}
56
61
 
57
- \MakeShortVerb\|
58
-
59
- \newenvironment{NoShortVerb}{\DeleteShortVerb\|}{\MakeShortVerb\|}
60
-
61
62
 
62
63
  \newcommand{\mysection}[1]{\subsection*{#1}}
63
64
 
@@ -284,9 +285,7 @@
284
285
 
285
286
  \lstset{language=C++}
286
287
  \lstset{columns=flexible}
287
- %\lstset{basewidth={1em,1em}}
288
288
  \lstset{keepspaces=true}
289
- \lstset{morekeywords={string,include,cin,cout,endl}}
290
289
  \lstset{stringstyle=\ttfamily}
291
290
  \lstset{commentstyle={}}
292
291
  \lstset{numberstyle=\tiny\sffamily}
@@ -296,14 +295,12 @@
296
295
  \lstset{showstringspaces=false}
297
296
  \lstset{upquote=true}
298
297
  \lstset{texcl=true}
299
- \lstset{literate={->}{$\rightarrow$}1 {<=}{$\le$}1 {>=}{$\ge$}1 {!=}{$\neq$}1 {<<}{$<\!\!\!<$}2 {>>}{$>\!\!\!>$}2}
300
- \lstset{xleftmargin=0.25cm}
301
-
302
- %\lstMakeShortInline@ Aquesta comanda el principal, perquè aquí hem potinejat les @,
303
-
304
298
 
305
299
  \renewcommand{\footnote}[1]{ (#1)}
306
300
 
301
+ % for backward compatibility but deprecated
302
+ \providecommand{\CPP}{C++}
303
+
307
304
  \newcommand{\UseHaskell}{
308
305
  \lstset{language=Haskell}
309
306
  \lstset{columns=fullflexible}
@@ -318,5 +315,12 @@
318
315
  \newcommand{\UsePython}{
319
316
  \lstset{language=Python}
320
317
  \lstset{columns=fullflexible}
318
+ \lstset{literate={<=}{$\le$}1 {>=}{$\ge$}1 {/=}{$\neq$}1 {->}{$\rightarrow$}1 {=>}{$\Rightarrow$}1}
319
+ }
320
+
321
+ \newcommand{\UseCPP}{
322
+ \lstset{language=CPP}
323
+ \lstset{columns=fullflexible}
324
+ \lstset{literate={<=}{$\le$}1 {>=}{$\ge$}1 {/=}{$\neq$}1 {->}{$\rightarrow$}1 {=>}{$\Rightarrow$}1}
321
325
  }
322
326