### Fefer_Ivan's blog

By Fefer_Ivan, 9 years ago, translation,

Good night/dawn/morning/day/dusk/evening/night, Codeforces!

Today I am glad to present you the latest features of the Polygon — the system for creation and preparation of programming problems and contests. All Codeforces Rounds are made using Polygon.

New features are concentrated around test script.

#### Part one. Test autonumeration

The first new feature allows you to automatically numerate tests.

gen_n 5 10 1 > 57
gen_n 5 10 2 > 58
gen_n 5 10 3 > 59
gen_n 5 10 4 > 60
gen_n 5 10 5 > 61


you can now write this

gen_n 5 10 1 > $gen_n 5 10 2 >$
gen_n 5 10 3 > $gen_n 5 10 4 >$
gen_n 5 10 5 > $ Dollar sign, used to mark autonumeration, stands for the first unused test index. So, for example: gen 1 >$
gen 2 > $gen 4 >$
gen 5 > $gen 3 > 3  will be translated to gen 1 > 1 gen 2 > 2 gen 3 > 3 gen 4 > 4 gen 5 > 5  But don't you think, that dollars will be replace with actual numbers upon saving the script. It would be too easy and boring. Of course, they stay. If you enter the script from example above and save it, you will see this: gen 1 >$
gen 2 > $gen 3 > 3 gen 4 >$
gen 5 > $ If you delete any test, all dollar tests will be renumerated instantly and they will still be dollars instead of exact nunbers. Also, did you now, that you can drag and drop tests to renumerate them? For example to move 40th test to the 7th position? This feature is very old, but it is rarelly noticed, so I decided to remind you about it. Dollar tests are also drugable. But there is always a fly in the ointment. We decied not to support dollars for generators, which generate multiple tests. They have syntax like this gen > {5-10,12,15}  So generator must produce 7 tests and put the to files 05, 06, ..., 10, 12, 15. So if we made them dollars and delete test number 1, we will get {4-9,11,14} instead of {5-10,12,15}.But the generator is not changed and still produce files 05, 06, etc. To avoid such problems, generators with file output does not support dollars. #### Part two. Scripts for generating scripts Now you can write script using Freemarker Template Engine, that will be executed inside the Polygon and the result will be used as test scritp. So for example instead of this gen 10 1 1 >$
gen 10 1 2 > $gen 10 1 3 >$
gen 100 4 1 > $gen 100 4 2 >$
gen 100 4 3 > $gen 1000 9 1 >$
gen 1000 9 2 > $gen 1000 9 3 >$
gen 10000 16 1 > $gen 10000 16 2 >$
gen 10000 16 3 > $ we can just write this <#assign n = 1> <#list 1..4 as pow> <#assign n = n * 10/> <#list 1..3 as i> gen${n} ${pow * pow}${i} > \$
</#list>
</#list>

You can find a brief tutorial about Freemarker at https://polygon.codeforces.com/docs/freemarker-manual. To find more details about the language you can read the official documentation.

But, script must be always consistent with the test table. It adds some limitation to the use of Freemarker.

• It is impossible to delete, edit or move script test using web-interface. To do it, you must edit the script directly.

• It is necessary to use dollars instead of indices. This limitation allow us to move manual test to any possition without changing the script.

• Dollars are not supported by multiple test generators, so it is impossible to use them inside Freemarker script. But, in my opinion, if you already wrote program, that generates all tests, why would you need Freemarker : )

As you will see, there are two new buttons near Save Script: Preview Script and Run Script.

Preview Script shows you the final result — which test will get which generator line.
Run Script replaces your Freemarker script with old-style script, in other words, with the sequence of generator lines. You can use this button, if you do not need Freemarker any more? but could use some of the locked features. Please note, that this button only replaces the script in the text field. You need to save it by pressing Save Script button.

That is all for now. I hope new features will make it easier for you to prepare problems for Codeforces Rounds and other contests.

With best regards, Ivan.

• +132