Egor's blog

By Egor19 months ago, translation, In English,
1. Installation
You need to download plug-in and configuration. Plug-in should go to %home_dir%\.IntelliJIdea10\config\plugins (if directory plugins is absent you need to create it), also you should include chelper.jar to class path of your project (Project Structure -> Dependencies -> Add Single Entry Module Library...). After that you need to edit configuration (see next section) and put it in project root. That's it — you are all set. For TopCoder you would need moj plugin for Arena, manual and download link is here

2. Configuration
As a general note, if some property in configuration represents a folder you must enter relative path from project root (using / instead of )
inputClass - full qualified name of class used for input (like java.util.Scanner). This class should implement method next that returns String — next token from input — and it should have constructor that takes InputStream as only argument
outputClass - full qualified name of class used for output (like java.io.PrintWriter). Ouput class shoud has constructor, that take OuputStream and one that take Writer as parameter and also method close.
excludePackages - comma separated list of package prefixes. Classes from such packages would not be inlined but rather imported. In most cases you should leave it as is
outputDirectory - directory where full source code would be stored. Should be under source and in default package (for example, if you create standart idea project, "src" spould be ok)
author - content of @author tag in. If empty no author tag would be created
archiveDirectory - directory where tasks would be archived. Should not be under source
defaultDirectory - direcory where tasks would be created by default. Should be under source in non-default package (for example src/my/package)
topcoderDirectory - directory where moj puts its TopCoder stubs. Should be under source in default package (e.g. src)
enableUnitTests - should be true if you want unit tests to be created and false otherwise
testDirectory - directory where tests would be stored. Shoud be under source
After configuration change you need to reload project for changes to take effect

3. Actions
I would recommend to add following actions on main toolbar (Customize Menus and Toolbars... from context menu of toolbar, actions are in Plug-ins->CHelper): New Task, Edit Tests, Archive Task, Delete Task, Create Codeforces Tasks.



New Task (Alt+F2) — creates new task in defaultDirectory
Edit Tests (Alt+F5) — opens test editor

Archive Task (Alt+F6) — archives task (deletes all it files and stores them in archive, also creates unit tests if configured to do so)
Delete Task - deletes task and all associated files
Parse Contest - creates all tasks for particular contest (currently Codeforces, CodeChef, E-Olimp and Timus are supported).

Parse Task - creates single task.

Site Contest ID Problemset task ID Contest task ID
Codeforces contest_id (131) contest_id letter (131 A) contest_id letter (131 A)
CodeChef contest_code (NOV11) problem_code (GCD2) contest_code problem_code
(NOV11 DOMNOCUT)
Timus contest_id (101) problem_id (1000) contest_id problem_number (101 1)
Copy Source (Alt+F8) — copies content of Main.java to clipboard. This is useful for judges that do not support submission of file

4. New Task dialog

Name - task class name
Test type - type of tests — either single test per file, number of tests and then tests themselves or just some tests until some condition is met. You need to throw UnknownError in last case to indicate that there would be no more tests
Input type/Output type - input/output type. Standard — stdin/stdout, Task_id — file input/output with file names %Name%.toLowerCase() + ".in"/".out", Custom — just file input/output, names provided in separate text fields
Heap memory - memory limit
Stack memory - stack size limit (defaults are same as codeforces)

5. Task files
For each task 2 files is creates. In main task class there is one method:
void solve(int testNumber, %input% in, %output% out)
testNumber — 1-based index of test in file
In checker class there are 3 methods:
String check(%input% input, %input% expected, %input% actual)
should return null if answer is correct, non empty string if answer is wrong and empty string to run default checker
double getCertainty()
returns certainty for double comparision in default checker
Collection<? extends Test> generateTests()
additional generated tests

For TopCoder tasks the only class would contain method from problem statement. Task would be created automatically when you opens problem in TopCoder client (if moj properly configured)
 
 
 
 
  • Vote: I like it  
  • +29
  • Vote: I do not like it  

 
19 months ago, # |
  Vote: I like it 0 Vote: I do not like it
Can I use IntelliJIdea to code in C++ ? Are there some plug-in to do that ?
 
19 months ago, # |
  Vote: I like it 0 Vote: I do not like it
I have a problem,when go add actions , not show me plugin chelper :(,
  •  
    19 months ago, # ^ |
      Vote: I like it +1 Vote: I do not like it
    You either had not copied it to correct folder or had not restarted Idea since
 
»
17 months ago, # |
  Vote: I like it 0 Vote: I do not like it
So, Egor, you are using IntelliJ IDEA as your main IDE for contests ?
Thx :D
 
»
17 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

I have some problems with your CHelper - plugin :-?

I've tried it with both IntelliJ IDEA 11 and 10, and I can't get it working
I did it in order :
1. Install IntelliJ IDEA 10
2. Copy chelper2.33.jar to config/plugins directory
3. Add CHelper's actions to the toolbar
4. Create new Java Module project (with src directory)
5. Copy chelper.properties to src directory
6. Add chelper2.33.jar to the new project's classpath
7. Try the Chelper's actions ... and it didn't work ...

Anybody has the same issue ?

Thx alot :)
  •  
    »
    »
    17 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    Had you restarted Idea after copying chelper.properties?
    •  
      »
      »
      »
      17 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it
      yes, I had :(

      thx for your reply :D
      •  
        »
        »
        »
        »
        17 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it
        Just noticed - you copied chelper.properties to src directory, but it should be in project root
        •  
          »
          »
          »
          »
          »
          17 months ago, # ^ |
            Vote: I like it 0 Vote: I do not like it
          thank you for your support, it's working now :D

          oh, if i change my settings in chelper.properties, i will also restart the IDE too ?
          •  
            »
            »
            »
            »
            »
            »
            17 months ago, # ^ |
              Vote: I like it +3 Vote: I do not like it
            Yep, would change it in next version
            •  
              »
              »
              »
              »
              »
              »
              »
              17 months ago, # ^ |
                Vote: I like it 0 Vote: I do not like it
              oh, can i have another question, please ?

              How can I define my own Input Class ? Is there any "template" feature ?
              •  
                »
                »
                »
                »
                »
                »
                »
                »
                17 months ago, # ^ |
                  Vote: I like it +3 Vote: I do not like it
                You just need to make sure that your class takes InputStream as argument and has method next, which returns next token from input as string. Everything else you can write as you like
                •  
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  17 months ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it
                  I mean that how can I put my class definition automatically :-?

                  Should I copy & paste it manually to the Main.java ?
                •  
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  17 months ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it
                  You just need to write class and put it somewhere under your source (e.g. in src/nova directory) and then fill nova.MyInputClass under inputClass in chelper.properties
                •  
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  17 months ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it
                  thx to your helping, i've got it working :D

                  also thx for such an useful, and ... wow plug-in :D :D :D
                •  
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  17 months ago, # ^ |
                  Rev. 2   Vote: I like it 0 Vote: I do not like it

                  deleted

 
»
17 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

To Egor,

Your plugin have a few "bugs" with Topcoder SRM Task :D. I've used it on SRM 530 and 531 and found some issues :D

  1. CHelper can't "parse" the task. When I open a task, there is only moj created code file and it isn't parsed into CHelper's TopCoder Task. I had this issue with task UnsortedSequence (SRM 531 — Div 2 — 250 Task), another tasks just work fine :)

  2. Wrong example input/output parsed. I'm not sure it's CHelper's problem or just moj's :-?. Had this issue with task GogoXCake (SRM 530 — Div 2 — 500 Task), another tasks just work fine :)

Just a "report" for you :D, hope you will see and fix them soon :D

Again, thanks for such an useful plugin :D

  •  
    »
    »
    17 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I'll look into it

  •  
    »
    »
    17 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I too faced the same problem in 531 Div2 -250.

  •  
    »
    »
    16 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    For SRM 531 D2 250 empty arrays were handled incorrectly. I will fix this ASAP As SRM 530 currently unavailable I'll look into that later

 
»
16 months ago, # |
  Vote: I like it 0 Vote: I do not like it

There is problem on creating ,parsing contest,none function work from toolbar

  •  
    »
    »
    16 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Please help me

  •  
    »
    »
    16 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Nothing is working or only contest parsing?

    •  
      »
      »
      »
      16 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Now contest parsing work ,how will it generate automatically Main file,it is not working

      •  
        »
        »
        »
        »
        16 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        This is my chelper.properties file inputClass = java.util.Scanner outputClass = java.io.PrintWriter excludePackages = java.,javax.,com.sun. outputDirectory = src author = Vikash archiveDirectory = archive/unsorted defaultDirectory = src/My topcoderDirectory = topcoder testDirectory = lib/test enableUnitTests = false

      •  
        »
        »
        »
        »
        16 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        It should generate the Main file when you run or debug created configuration

        •  
          »
          »
          »
          »
          »
          16 months ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          When I select contest id 131(or any) in codeforces it doesn't generate any thing in default directory

 
»
16 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Hi Egor, Can you tell me how the inline functions work...I cannot figure it out..Suppose I have a method isPrime(int) that returns whether the number is prime or not.I want to use it directly and not write the whole thing everytime.I think the inline code does exactly this.But I dont know how to use it.Could you tell me or better demonstrate it with an example???

  •  
    »
    »
    16 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    You need to create some class, like IntegerUtils and create static method isPrime. Then you can use it in your solutions

    •  
      »
      »
      »
      16 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      And where do I have to save that class??

      •  
        »
        »
        »
        »
        16 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Anywhere it will be visible fromyour solution

        •  
          »
          »
          »
          »
          »
          16 months ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          I created a class algorithms in src and a static method isPrime(Object a) in that.Then I compiled it. After that when I go to a Task and write boolean check=algorithms.isPrime((Object)a) ,then it is shown in red .i.e. it cannot compile...What should I do...Should I have to restart??

          •  
            »
            »
            »
            »
            »
            »
            16 months ago, # ^ |
              Vote: I like it +2 Vote: I do not like it

            Are you sure your method was public?

            •  
              »
              »
              »
              »
              »
              »
              »
              16 months ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              Yes it is public...Do I have to change something in the properties file or put the class in a directory under the src??

              •  
                »
                »
                »
                »
                »
                »
                »
                »
                16 months ago, # ^ |
                  Vote: I like it +1 Vote: I do not like it

                Well, it should be somewhere under source — just like for any Java project

                •  
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  16 months ago, # ^ |
                    Vote: I like it -1 Vote: I do not like it

                  Ok. now its working .When I created a new directory under src and put the class in it.Thanks for the replies and your time:-) The thing I dont like in this is that it is showing all the methods in that class even if it is not called but some other method of that class is called ..Can this be changed??

                •  
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  16 months ago, # ^ |
                    Vote: I like it +1 Vote: I do not like it

                  In the created source (the one you will submit to the server) all unused methods will be removed

                •  
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  15 months ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  When I submitted a problem in topcoder SRM 535 using IntegerUtils class it gave an error regarding too much unused code.I think that inline code is not working..Its definatley not working on codechef where I can see my submitted solution

                •  
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  15 months ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  That is bug in TopCoder algorithm, I receive that warning quite regular, but never had my submission judged as UCR violation after I started to use Java. Can you point to your codechef submit where inlining/unused code removal had not worked?

                •  
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  15 months ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  I have messaged it to you.

                •  
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  15 months ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  Check emotionalBlind's comment at the bottom, maybe you have same problem

 
»
16 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I was solving a problem of Light OJ, but seems unused codes are not removed in my Main File.

Here is my code: http://ideone.com/gsgDb

Here readLong is not removed, which is actually unused.

  •  
    »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Strange, not repetable on my computer By the way, you can use Test Type: MULTI_TEST, that's exactly why that type was created

    •  
      »
      »
      »
      15 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Did you mean MULTI_NUMBER?

      BTW, do you suggest me to do anything to make unused code remove working? I'm using chelper2.33.

      •  
        »
        »
        »
        »
        15 months ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        Yes

        It seems for whatever reason Idea considers readLong method as used. Could you open your created source (i.e. Main.java) in Idea and see if method name is grayed out as unused or not?

        •  
          »
          »
          »
          »
          »
          15 months ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Yes, it was grayed out.

          But problem is resolved now.

          I changed outputDirectory = src from outputDirectory = src/output

          And now it's working. Sorry, I think I didn't read the instructions carefully.

          Thanks for this awesome software.

 
»
15 months ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

I changed the properties file and it does work for codeforces and codechef. And when I see my code at the topcoder practise arena it does indeed have the unused codes+every time I run the code for topcoder problems it gives a warning "OutPut directory should be under source and in defualt package " for only topcoder problems but then it runs...What should be done??

  •  
    »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I had the same problem but it seems I had not configured my directories correctly. Now, it's ok. My directories in properties are: outputDirectory = src, archiveDirectory = archive/unsorted, defaultDirectory = src/mypackage, topcoderDirectory = src And make sure moj outputs to your src directory. Thanks for the great plugin, Egor!

 
»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Thank you for your plugin. It's great.

 
»
11 months ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

Thank you for your great work! But I can't find the "%home_dir%.IntelliJIdea10configplugins" means, so I can't continue to set up this plugin in my PC corrcetly.. Help! Thank you!

  •  
    »
    »
    11 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Launch IntelliJ and choose

    File -> Settings -> Plugins -> Install plugin from disk -> path_to_chelper2.41.jar

    •  
      »
      »
      »
      11 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thank you for your reply! But I mean I don't know where to mkdir the IntelliJIdea10configplugins, that means I don't what "“%home_dir%" mean. Is it the Home directory "~/"? Thank you!

      •  
        »
        »
        »
        »
        11 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I fixed path that got broken after markdown introduction

        Yes, that's home directory

        •  
          »
          »
          »
          »
          »
          11 months ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Oh, got it! Thanks all~

        •  
          »
          »
          »
          »
          »
          11 months ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          BTW, in the Checker file, there are some imports I can not find in the project.. They are "import net.egork.chelper.task.Test; import net.egork.chelper.tester.Verdict;" And my config is " inputClass = lozy.InputReader outputClass = java.io.PrintWriter excludePackages = java.,javax.,com.sun. outputDirectory = src author = Lozy archiveDirectory = archive/unsorted defaultDirectory = src/cf topcoderDirectory = topcoder testDirectory = lib/test enableUnitTests = false " Is there any problem in my config file or should I do some other works? Thanks a lot!

          •  
            »
            »
            »
            »
            »
            »
            11 months ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            "...also you should include chelper.jar to class path of your project (Project Structure -> Dependencies -> Add Single Entry Module Library…)"

            •  
              »
              »
              »
              »
              »
              »
              »
              11 months ago, # ^ |
              Rev. 2   Vote: I like it 0 Vote: I do not like it

              Sorry for my carelessness... I didn't see the word "also"... Thank you for your reply and your time!

 
»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

how can i use chelper in eclipse IDE ?

  •  
    »
    »
    2 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Idea plugins are incompatible with Eclipse