ekzhang's blog

By ekzhang, history, 4 years ago, In English

Hello all,

Like you, I enjoy solving Codeforces problems on the go. However, sometimes I am not working on my computer with all my environment and setup. There are many automated problem parsers and test runners to help make solving Codeforces problems painless, but they all require a complicated installation process.

About a year ago, I was introduced to CS Academy, which I thought had an amazing interface for solving problems. It shows the problems and your code side-by-side, and you can automatically run your program on the example test cases. Also, there is auto-saving in case you accidentally close your window. Why can't we have this for Codeforces?

I couldn't find anything on the web that was easy to set up and fun to use, so I made my own online workspace at wkspace.herokuapp.com.

Screenshot of wkspace

Here are some features:

  • No sign-up or installation required
  • Parses Codeforces problems and displays them side-by-side with code
  • One click to run your code on all example test cases (for non-interactive problems)
  • One click to submit your code to Codeforces (if logged in)
  • Auto-saving of code in the cloud
  • List workspaces you have recently edited
  • Share a read-only paste of your code by link
  • Support for new versions of the most common languages (C, C++, Python, Java, Ruby)
  • Configurable themes (Monokai, Dawn, Solarized)
  • Configurable keybindings (Vim, Emacs)

I have been using and developing this myself for the past year, and it is fairly stable now, so I would like to share it with you. Please let me know if you have any feedback on how to improve it!

Note: The code is open source and available at https://github.com/ekzhang/wkspace.

Thanks to Herman Došilović for making the Judge0 API, which is used in this project.

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

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

Very cool feature! But there seems to be a problem with the tasks that have drawings in them. For example on task 1344E, the train paths do not appear on your workplace.

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

    Thank you! You are right, the scraper for problem statement text is not perfect. Codeforces markup is complicated, so it is not very easy to parse. It is definitely on my wishlist to have a perfect parser. However, I think the current parser is a good balance between getting the details of the problem statement and being robust to changes in the Codeforces website.

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

It's really amazing.
I am just curious to know, which platform are you using for code execution in backend, is it paid or free? If i use it during a contest and many people are using it, will it be able to bear the load and won't take longer times to execute the code(like queues on CF)?

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

    Thank you! I am using the public Judge0 API as mentioned above, which has had 99.8% uptime in the last 30 days. From my experience, I do not believe you should see any issues with availability during Codeforces contests.

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

      Thank you for your response. I would like to mention that the load option isn't working for me(btw load means to upload a local file or something else there?).
      UPD : fixed, now it's working.

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

        Nice catch, that's exactly right. Should be fixed now if you refresh to clear your cache. :)

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

Your vim keybindings are not complete; the command :%s/foo//gn does not work as intended. Maybe that's too upstream...

By the way, most of the functionalities could probably be replicated by a project template at repl.it. Your project looks nicer, though.

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

    You're right about the vim keybindings. I am also skeptical that no other editor can simulate "real" vim perfectly. Even a big project like Ace, which I am using, doesn't get everything right. :)

    However, I respectfully disagree with your second point about repl.it. The goal of this project was to make a domain-specific environment to solve competitive programming problems on any machine with the minimum amount of friction. Repl.it is a great tool for running and sharing code (I use it myself), but it is definitively not a competitive programming tool. It does not parse problem statements or allow you to run your code on tests with standard time/memory constraints. It's also not fine-tuned for competitive programmers — for example, the only C++ compiler offered is Clang, instead of GCC, so you can't use builtin functions.

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

      Yes, you are probably right; I gave it 20 seconds of thinking, and you worked this for a year... But, there are always "HN Dropbox" comments, and someone else would've said something similar if I didn't.

      By the way, you are the SetWithFriends author? You should have set up a buymeacoffee earlier this year, I would have bought for sure...

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

        Thank you, I'm happily surprised that you've heard of Set with Friends. It's a small world :)

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

Nice thingy, but how can we be sure that our codes wont be shared during an ongoing contest?, i think you can use some sort of hashing for this(just an opinion, i'm neither experienced nor a programmer)

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

    Short answer: Your code isn't accessible to anyone unless they have the link. So as long as you do not share the link, it will be fine.

    In more detail: The IDs of each workspace in the URL are generated using Crypto.randomBytes(), which produces cryptographically strong pseudo-random data. Each ID is 6 bytes written as a string of length 8 in base-64 format, so it would take 2^48 guesses for an attacker to find your code.

    For comparison, YouTube video IDs (including unlisted videos) are 8-byte integers, which would take 2^64 guesses. This is appropriate because YouTube is several orders of magnitude larger than this application. :)

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

I think it would be perfect to make this an app. Yes I know there are other editors like CP Editor, but I really loved your interface! Simple and Sweet!

Edit: I didn't know it was the same interface as CS academy, I hadn't tried CS academy.

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

it would be better if you parse problem from url also

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

Hi I really appreciate this web app because I only have a Chromebook and repl.it is super annoying to submit problems. There seems to be a problem where every time you refresh the page all the settings revert to default. Also, How long will your code be saved if you suppose accidentally close it or something happens such that the web app would close?

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

    Your code is stored securely in a cloud database. At the moment, it will remain available indefinitely. Storage happens to be pretty cheap :)

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

    I use Chromebook and I have Atom installed on it and it works fine locally.

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

For some reason the special tasks don't have the fancy text on my screen (like when they define the bounds and stuff), so i got stuck on problem 1A because i kept on thinking the bounds were 109 instead of 10^9 LOL

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

    Sorry about that! Some older tasks (e.g., two-digit round numbers) aren't parsed very well. I think that Codeforces has changed their LaTeX markup system in the past, and this leads to some inconsistencies.

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

      Oh, okay, that's pretty cool to know. I'm really enjoying it btw it's super compact :D

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

It crashes when I press Run, and Test spins endlessly, what should I do?

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

    I just tested it, and both buttons are working for me right now. What browser and language are you using?

    https://i.imgur.com/5DQXHPZ.png

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

      It was a compiler error, oops. I was using C++ and Chrome and the template had LL but I wrote ll. Is there a way to see when there is a compiler error? When I click "Compilation" tab at bottom nothing shows. When I click Run on code with compiler error it just says Error: [object Object] in a pop up message.

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

        Hm, this seems like a recent issue upstream with Judge0. It's mangling the compile errors somehow, and that creates non-UTF8 characters, which break the HTTP response parser.

        I don't have too much bandwidth to implement a workaround for now... so maybe just wait a couple days? I expect it to be fixed relatively soon.

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

ekzhang thank you for such an amazing interface.

I have a humble feature request which others may also find helpful. Option to switch to Fullscreen/Distraction Free/ Minimize problem description to a sidebar as we might not always want to see it at a certain point in time and can look up when required?

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

    Thanks, I went ahead and implemented that since it was simple. Glad you're enjoying the site!

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

Great work, many will find it really helpful. :)
What is the test tab for? I presume it's for testing the samples,but it ain't very helpful for problems with multiple answers. for example, here, the tests showed me wrong answer so i had to submit and it got AC.
So my point is, maybe it would be better to keep the samples as input by default, and just show the user the output for it when he clicks "test". I think it would be more helpful in general for most problems.

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

This is not working sir I mean the sir is just loading for past 10 minutes ...

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

Hey, can you add a feature where you can save your template? Right now, for every new problem, I have to copy my template from Visual Studio. Thank You for this amazing workspace!! Hey, I also noticed you can't look at figures given in the question. Can you pls look at this once?