Skip to content

Simple XML based language created for Competetive Programmers to quickly generate random tests for competitions

Notifications You must be signed in to change notification settings

antonigoles/CPTG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 

Repository files navigation

CPTG Docs

Simple XML-based language created for Competetive Programmers to quickly generate random tests for competitions

Table of contents

  1. Document structure
  2. Variables and constants
  3. Sequences
  4. Tags and Parameters documentation
  5. Examples

Document Structure

Every .cptg file should start with <test> tag and end with </test> tag


<test>
    <!-- variables, sequences, etc -->
</test>

Variables and constants

<var/>

  • Variable is used to display various types of randomly generated data. By default, a variable is a Number in the range of 0-9, but it can be modified with parameters.

<const/>

  • Constant is similar to variable, but the only parameter it supports is value which is used to specify their... value and unlike variable, constant is static

Sequences

<seq/>

  • Sequence is used to repeat a group of tags without copying and pasting (you can think of it as a loop)
  • you can specify different parameters to make it work differently
  • sequences can be nested e.g.
<test>
    <seq times="3">
        <seq times="2">
            <const value="1"/>
        </seq>
    </seq>
</test>
<!-- Output: 1 1 1 1 1 1 -->

Tags and Parameters documentation


<var>

available parameters

  • type
    • default: Number
    • used to specify the type of data that will be generated
    • available values:
      • Char
      • Number
      • Float
      • String
  • range
    • default:
      • for Number and Float:
        • 0:9
      • for String and Char:
        • abc
    • used to specify variable generator range
    • available values:
      • for Number and Float:
        • n1:n2 (random numbers from n1 to n2)
          • e.g: <var type="Number" range="-900:900" /> random number in the range of [-900;900]
      • for String and Char:
        • abc generates random lowercase Latin alphabet letter
        • ABC generates random uppercase Latin alphabet letter
        • special generates random "special character"
          • list of special characters:
            • ! @ # $ % ^ & * ( ) - _ + = { } [ ] : ; " ' < > , . ? / | \ ~
        • all generates random lowercase Latin alphabet letter, uppercase Latin alphabet letter or random special character
  • length
    • default: 3
    • only avaliable fo String and Float
      • for String it specifies the number of characters
      • for Float it specifies the number of places after the decimal point


<const>

available parameters

  • value
    • default: None, must be specified
    • specifies constant value


<seq>

available parameters

  • times
    • default: 1
    • specifies how many times sequence will repeat


<br>

  • adds a breakpoint (\n)
  • nothing else


Examples


Code

<test>
    <!-- just putting <var/> here without any parameters will
    generate a random number from 0 to 9 -->
    <var/> 
</test>

Example Output

2


Code

<test>
    <!-- sequence example  -->
    <seq times="5">
        <var/>
    </seq>
</test>

Example Output

2 3 1 5 6

Code

<test>
    <seq times="6">
        <seq times="5"> 
            <var/>
        </seq>
        <br/>
    </seq>
</test>

Example Output

2 3 1 5 6
7 9 1 2 3
0 9 8 2 9
2 0 3 1 9
4 0 9 2 8
9 0 2 1 3

Code

<test>
    <!-- variables can be of different types -->
    <seq times="3">
        <var type="Char" range="abc" />
        <var type="Char" range="ABC" />
        <var type="Char" range="special" />
        <var type="Char" range="all" />
        <var type="String" range="all" length="5" />
        <br/>
    </seq>
</test>

Example Output

a B & # b$%cA
b D ^ $ sdnD@
p L ( w wdaio

Code

<test>
    <!-- you can also define constants -->
    <const value="5"/>
    <const value="test"/>
    <const value="123"/>
</test>

Example Output

5 test 123

Code

<test>
    <!-- you can also add breaks -->
    <const value="5"/>
    <const value="test"/>
    <br/>
    <const value="123"/>
</test>

Example Output

5 test 
123

@ maintained by github/foealke

About

Simple XML based language created for Competetive Programmers to quickly generate random tests for competitions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published