mnaeraxr's blog

By mnaeraxr, 4 years ago, In English

Hi Codeforces,

I wanted to share with you all acmX, an extension for vscode I started coding half a year ago for myself. Since then it has evolved a lot and it has some features that might be useful for some of you:

  • Contest/Problem parsing. (Via Competitive-Companion extension).
  • Running solution against testcases.
  • Automatic verdict results (OK, WA, RTE, TLE, CE).
  • Manage test cases easily.
  • Stress solution.
  • Support for multiple languages.
  • Smart copy (Use custom algorithm library and merge code with caide-cpp-inliner).

Check the wiki to read about all features.

Installation

In the vscode install the extension from the marketplace

Usage

Getting started

Check the README for more details.

Discussion

All the discussion happens in the github issue tracker or in the Telegram group. Feel free to ping me through any of those if you have any suggestion or hit some error.

Thanks Devil and Agile_Eagle for encouraging me write this blog.

  • Vote: I like it
  • +110
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
Rev. 2   Vote: I like it +57 Vote: I do not like it

If you attach a gif file in a codeforces post, it's not enough to provide a gif url under an img tag: it converts to a static image due to some reason (maybe scaling because of predownloading to cf servers in order to remain available for eternity or smth). What worked for me is to provide a gif url which doesn't end with .gif. For example, you can upload your image on imgur.com, then get a link (like https://i.imgur.com/tXiDknq.gif) and just replace the extension by, for example, png: https://i.imgur.com/tXiDknq.png (idk how it works that such images don't become static, yet become predownloaded. Maybe due to some format parsing error. If so, please don't fix this)

result
  • »
    »
    4 years ago, # ^ |
      Vote: I like it +14 Vote: I do not like it

    Thanks for letting me know (and the fix) didn't notice myself the gif was not working :(

»
4 years ago, # |
Rev. 2   Vote: I like it +10 Vote: I do not like it

I just tried for an hour to to some basic steps with the tool. Unfortunatly I did not manage to use it. I was able to parse a problem once by using the chrome extension (if vscode is running somehow directories in vscode are created).

Then I configured my code template and tried again, without success, nothing works any more. A simple step by step tutorial would be helpful, I feel it is complecated on first use. I get a lot of meaningless error messages.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    Same problem.When i am clicking the competitive companion button a contest is create but nothing is inside that folder.

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Can you share which contest are you trying to parse? I used successfully right now with Atcoder Grand Contest 044.

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it +10 Vote: I do not like it

      I think you should check if PORT is the same in VS code and extension.

  • »
    »
    4 years ago, # ^ |
    Rev. 2   Vote: I like it +3 Vote: I do not like it

    To use competitive companion extension, it is required to have an instance of vscode open, since it spawns a server listening for requests from companion.

    There is a step by step tutorial in the wiki.

    Here is how my settings for the extension looks like:

    https://i.imgur.com/NEzLlZ6.png

    Image

    The ones with the blue side bar, are those who I changed from its default value.

    Can you please share the meaningless error messages. Consider joining the Telegram group for faster assistance :)

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it +10 Vote: I do not like it

      Thanks for your help. I think my basic setup does not work as expected.

      After startup of vscode I get error messages in integrated terminal

      fendriss@note-ibm-388 /cygdrive/c/Users/fendriss
      $ type "C:\Users\fendriss\.acmx\attic\stderr"
      bash: type: C:\Users\fendriss\.acmx\attic\stderr: Nicht gefunden.
      

      I assume this has to to with the cygwin configuration, that bash is not able to work with windows paths.

      Then it shows me immediatly a notification

      Compilation Error. C:\Users\fendriss\.acmx\checkers\wcmp.cpp
      Source: acmX (Extension)
      

      I assume that has to do with the configuration of the C/C++ toolchain. Where/How do I configure which compiler is used, the flags etc...? I did not found anything looking like that.

      And, how to "reset" the installation? While trying to make it run I changed several configuration files. To do the installation from scratch, what should I delete, is $HOME/.acmx enough?

      • »
        »
        »
        »
        4 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        To do the installation from scratch, what should I delete, is $HOME/.acmx enough?

        yes, but doing this won't solve your problem. See below

        Compilation Error. C:\Users\fendriss.acmx\checkers\wcmp.cpp

        On startup, the first time it will try to compile the default checker for your platform. Notice in the folder C:\Users\fendriss\.acmx\checkers the files testlib.h and wcmp.cpp. The default compilation command for c++ is failing, notice that it relies on g++ being in the default path, which is not your case.

        To fix it, edit the command line that you can use to compile c++ files in $HOME/.acmx/languages/cpp.json and reload vscode. Read about the format of the cpp.json here.

»
4 years ago, # |
  Vote: I like it +10 Vote: I do not like it

I am using it for over 6 months and totally satisfied with its performance. Although there is one thing, I generally parse problems individually instead of the whole contest, So it would be great if I parse other problems, it should open its folder correspondingly instead of just creating it.

For ex : If I already parsed A problem of the contest, then if I parse B, it should open editor for problem B right away. It doesn't do that, just creates the folder and then I have to waste my 10seconds(closing all test files and sol.cpp from the previous problem, Ctrl + B, then clicking on the folder, then clicking on sol.cpp, Ctrl + B again) which sometimes seems annoying to me during contests.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks for the feedback ma_da_fa_ka. I think I can solve part your issue at the moment.

    I have two unsolved problems which needs to be solved to completely address your issue:

    1. Figure out how to close open files automatically (i.e. test cases and files from different problems).

    2. When a new contest is parsed, a new folder is created and a new vscode instance is launched. I don't have control over the new instance right away, so I can't directly open main solution on start up. See relevant issue.

    However point 2. is not your case, since parsing a new problem from a contest which is already open doesn't launch a new instance. In that case point 2 can be easily addressed which will "solve" your problem, except that other files aren't going to be closed. I created a ticket for this here.

    Temporarily, I suggest you to use Go to file(Ctrl+p) feature from vscode to open solutions without doing Ctrl+B. The caveat here is that all main solutions will have the same name, so you should look the folders where they are located.

    https://i.imgur.com/CV2M0wV.png

    Image
»
4 years ago, # |
  Vote: I like it +10 Vote: I do not like it

Is this extension useful for the python code or there are any other tools for cp with python??

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    It works with all languages given that you configure it. Check it here. By default it has support for python.

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

How I can Create fix template for all sol.cpp file?

»
3 years ago, # |
Rev. 2   Vote: I like it +10 Vote: I do not like it

for java programmers (on Linux)

step 1- -create a file named java.json -write this code in it { "preRun": [ "javac", "-d", "$OUTPUT", "$CODE" ], "run": [ "java", "-cp", "$OUTPUT", "Main" ], "ext": "java" } and save it in .acmx/languages/(find it in your drive most likely it will be in home/.acmx- you might have cpp.json and python.json in it ,leave them as they were).

Step 2 — create a template java file as Main.java (this will be used as your default template for submissions)and save it anywhere locally on your system.

Step-3 -Open visual studio code -> settings -search for acmx.template.solutionPath -here add the full path of your template file
i.e.-Main.java (eg-/home/rishabh/Templates/Main.java)

step -4 — follow the instructions given on extention page (now it will open Main.java file for you to use instead of sol.cpp.

Thanks to marX(developer) to help me setup this much