### ekzhang's blog

By ekzhang, history, 9 months ago,

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.

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
• 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.

• +419

 » 9 months ago, # | ← Rev. 2 →   +15 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.
•  » » 9 months ago, # ^ |   +9 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.
 » 9 months ago, # |   +20 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)?
•  » » 9 months ago, # ^ |   0 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.
•  » » » 9 months ago, # ^ | ← Rev. 2 →   0 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.
•  » » » » 9 months ago, # ^ |   0 Nice catch, that's exactly right. Should be fixed now if you refresh to clear your cache. :)
 » 9 months ago, # | ← Rev. 2 →   +3 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.
•  » » 9 months ago, # ^ |   +21 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.
•  » » » 9 months ago, # ^ |   +20 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...
•  » » » » 9 months ago, # ^ |   0 Thank you, I'm happily surprised that you've heard of Set with Friends. It's a small world :)
 » 9 months ago, # | ← Rev. 2 →   +16 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)
•  » » 9 months ago, # ^ |   0 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. :)
•  » » » 9 months ago, # ^ |   0 Thanks, i were expecting something like that :D
 » 9 months ago, # | ← Rev. 2 →   +10 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.
 » 9 months ago, # |   0 it would be better if you parse problem from url also
 » 9 months ago, # |   +18 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?
•  » » 9 months ago, # ^ |   0 Your code is stored securely in a cloud database. At the moment, it will remain available indefinitely. Storage happens to be pretty cheap :)
•  » » 9 months ago, # ^ | ← Rev. 2 →   0 I use Chromebook and I have Atom installed on it and it works fine locally.
 » 9 months ago, # |   +18 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
•  » » 9 months ago, # ^ |   +3 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.
•  » » » 9 months ago, # ^ |   0 Oh, okay, that's pretty cool to know. I'm really enjoying it btw it's super compact :D
 » 6 months ago, # |   0 It crashes when I press Run, and Test spins endlessly, what should I do?
•  » » 6 months ago, # ^ |   0 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
•  » » » 6 months ago, # ^ |   0 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.
•  » » » » 6 months ago, # ^ |   +1 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.
 » 6 months ago, # |   +8 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?
•  » » 6 months ago, # ^ |   +12 Thanks, I went ahead and implemented that since it was simple. Glad you're enjoying the site!
 » 6 months ago, # |   0 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.
 » 6 months ago, # | ← Rev. 3 →   +3 This is not working sir I mean the sir is just loading for past 10 minutes ...
 » 6 months ago, # | ← Rev. 2 →   +2 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?