Show HN: Science and math-flavored programming problems for beginners
projectlovelace.net
projectlovelace.net
I think you might enjoy it. Visit- https://en.m.wikipedia.org/wiki/Structure_and_Interpretation...
It’s easy to snipe a nerd, but nerd sniping a non-nerd.. That’s gold.
FWIW: - No margins on the side on iPhone in portrait. - Math formulas are clipped on the top in landscape.
Ah I'm no web dev so must have missed that margin issue. Was able to reproduce in tablet mode. Thanks for pointing it out!
Just would appreciate golang support, but i guess you will get feature requests for all languages anyways :)
I don't use Go so might take a while unless someone decides to swoop in and add support for it!
Supporting new languages takes some effort since we need to be able to run arbitrary Go code and communicate with Python. Definitely possible but requires some familiarity with both.
So far we've just been adding languages we know and use. Hoping to learn Rust soon so that might be the next language!
I think the reason we did it is so that we could visualize user output/solutions. You can learn new things by looking at your solutions to various test cases!
One example would be if you submit a solution (or just the code stub) to the Exponential growth problem, then your solution gets plotted and compared with the analytic solution and the correct solution: https://projectlovelace.net/problems/exponential-growth/
Also, unlike Project Euler where every solution is a number, a lot of scientific problems have solutions that are multi-dimensional arrays or multiple objects. So in this case, copy pasting your output becomes quite messy.
It's not trivial to add support new languages since the engine app that runs user-submitted code needs to be able to run arbitrary code in your chosen language and needs a way to communicate with Python (either directly or through JSON passing).
So far we've just been adding support for languages we know and use.
But indeed there are hundreds of languages out there that would be nice to support in some way. It might be neat to add a new submission mode where you're given a couple of test cases that you run manually then submit your solution manually.
Speaking of registration, it would be nice if we could log in using our Google accounts (ie. Sign in with <service>), rather than make another account with your site.
Also it would be nice if the site picked up your preferred language of choice after you've done at least one of the problems. I like coding in javascript, but I have to select it from the dropdown list each time I go into a problem to solve, and sometimes I forget to do so (defaulting to Python instead)
We thought it would be tedious to write tons of code to make sure users don't take the easy way out for each problem and language, so we figured we might as well allow it. We can't force users to solve the problem our way.
[0] - codewars.com
Yeah maybe we went a little too easy on the earlier problems but there will be plenty of harder problems coming up hopefully!
I actually think Project Euler gets hard pretty quickly but I'm no number theory wizard haha.
It would be nice to support uploading a binary or solution (like project Euler) or a CSV of test cases next to solutions. Maybe I'll try compiling rust to c and upload the c file
It's not trivial to add support new languages since the engine app that runs user-submitted code needs to be able to run arbitrary code in your chosen language and needs a way to communicate with Python (either directly or through JSON passing).
So far we've just been adding support for languages we know and use.
But indeed there are hundreds of languages out there that would be nice to support in some way. I'm gonna think about how we can add a new "submission mode" where you're given a couple of test cases that you run manually with any language then submit your solution.
People self-study text books without sending in their solutions to the publisher.
I do see that the engine is open source though. I'll look into contributing: https://github.com/project-lovelace
I guess we started simple so that the barrier to entry is low, but we should have some tougher and more interesting problems soon!
For running Javascript and Julia, it goes something like Python objects -> JSON -> read JSON in Javascript/Julia -> run code -> output JSON -> read user output from JSON in Python.
For C, we can call C functions directly from Python with some code for dealing with different types.
Not sure if this is the best approach (it's not super fast) but we've been learning as we go. We might be due for a refactor in case the next language we want to support doesn't fit into this pattern. I'm personally excited to learn Rust and maybe add support for it.
PS: Our stack is on GitHub in case anyone is interested in having a look: https://github.com/project-lovelace
I'm not a web developer by trade or anything so I'll have to learn how to secure the Docker container from malicious code. Hopefully Docker provides some amount of protection for now...
For today it's going to be old school htop + F9 haha.
* Results from the untrusted part inside container are returned using pickle. Which can be used to achieve arbitrary code execution outside container.
* no time limiting
* no memory limiting
* Untrusted code is run as root in the container which by default is same user as root outside container. From what I understand it isn't as bad as it was in earlier docker versions but still not great.
* untrusted code is run in the same process as semitrusted run_lang code, which means that the untrusted code with little bit of effort can manipulate reported execution time and memory usage
* for some languages correct_output is copied into the untrusted execution environment which means that solution could potentially just read the correct answers instead of calculating themselves
* none of the default capabilities are dropped which is probably more than what solution needs
* solution can freely create new files
Definitely not surprised that there are many security vulnerabilities...
I'm a grad student in computational science working on this as a hobby so building and securing websites is not something I know much about.
But now that someone is actually using it, I will take security more seriously.
Once I have some time I'll open a GitHub issue and compile a list of the security vulnerabilities you listed and will learn how to fix them.
This should be a good learning opportunity!
That's a good attitude to have but people are probably going to take over your host[s], vandalize your site and run up your bills long before you get a chance to do all the necessary learning. I don't think your current approach is actually all that easy to secure.
This website is a free open-source side project and not business critical.
There's probably some low hanging fruit in configuring Docker properly.
Disable ability to make submissions until you have more solid plan
Decide what is your goal. Do you want to make a judge system, do you want create tasks or do you want a platform with specific kind of tasks.
Get in touch with people involved in ICPC an IOI contests in your country. Even if you are not interested in those kind of algorithm tasks, there will be some people who are familiar with similar existing systems and could point you in the right direction.
Assuming your primary goal isn't to make a judge system itself, some other options are: * Evaluate the existing online judge systems. There are some open source ones like DOMjudge(https://www.domjudge.org/), CMS(https://cms-dev.github.io/index.html) and others . Consider if you reuse or extend them to suite your desired format. In the worst case maybe just the execution part can be reused. At least learn from their experience and mistakes creating and maintaining such systems.
* Many programming languages now have online REPL environments. Some of them open source. This is one more source of projects that provide sandboxed execution.
* If you have some budget, there are platforms that provide sandboxed exection as service oriented at your exact use case. Some examples are Sphere Engine https://sphere-engine.com/enterprise used by Sphere online judge and Kattis .
There a lot more different platforms with different style of programming tasks than what you listed in your FAQ. Some of looking for problem setters. Maybe one of them fits your type of tasks more. Or it can be a one off contest with slightly unusual problem set. Or maybe it can be a separate category on their system and you can advertise this category on your website.
Any chance of adding Rust to the list of supported languages?
Though, in that case, the solution is so trivial that t is completely unnecessary.
Don't think it's an idiom (at least not one that I've seen).
It's definitely not the nicest code, especially for simpler problems that are really one-liners but we figured lots of people would just click "submit" on just the code stubs.
Will begin solving all of them.
And I would like this to exists for a long time and I want it to be around when I teach programming to my little cousins, nephews and nieces and my future generation.
Add an option to Donate. Would love to do so.
But, why are the programs in Python instead of Ada, if it's Project Lovelace? For Python, maybe it could be Project Monty. Heh.
'[A]da Lovelace' sounds so nice and soothing to me. It's a really beautiful name. However, just 'Ada' doesn't do anything for me, but 'Julia' does the trick there. A programmer named Ada Lovelace and a programming language named Julia... those things make for really comforting echos in my mind, I don't know why. Like coming home chilled from winter's rainfall and bathing the brain in warm vanilla sauce.
I've used many of these same problems as small assignments when teaching programming to novices.
However all my assignments look much uglier. And looks do matter.
I'm also thinking of how we can add a "manual submission mode" that lets you use any language that you run locally.
We never expected this much traffic and everything is hosted on a tiny DigitalOcean server including the code runner haha. If you visit a bit later it should be much faster.
I can think of some ways to speed things up which I will try.
Also, I can not seem to submit solution to problem 'Compound interest'. I kept getting the following error, '...docker container is nonzero. Returning falcon HTTP 400.'. Sent you an email with the details.
You can check out the engine code on GitHub if you're interested in the details: https://github.com/project-lovelace/lovelace-engine