Embedding Code Problems

One of the things I’ve wanted to do on this site, pretty much since I registered the domain name, was to write coding tutorials aimed at students just starting out. Yes, there are tons of programming tutorials out there on the internet. But they seem to be either targeting those that already have some programming experience or not written in a way that’s friendly to beginners.

Just reading tutorials doesn’t seem very effective. At least, I don’t learn well that way and I assume that others are in the same boat. So I want to include a code either where visitors can type and work on their coding skills.

And it’ll look a little like this. In the editor below you can type in code to try and solve the problem. For this particular problem you’re implementing a method in Java that finds the largest value in an array of integers.


I also want to include working solutions whenever possible, and I found a great WordPress plugin that makes it pretty easy to create spoiler style blocks so visitors can see my solutions to problems.

Solution
public int findLargest( int[] nums ) {
    int big = Integer.MIN_VALUE;
    for (int n: nums)
        if (n > big)
            big = n;
    return big; 
}

How does it work?

The code’s compiled using a system that I’ve been developing over the past few summers. Basically I got tired of manually grading code submissions and created a tool where students can submit code and it’s automatically graded. A WordPress plugin links that system to this site.

Only catch is that, with the WordPress plugin, the code you type in isn’t saved between visits. There’s a way around that, but it requires creating an account on this site and I wanted the tutorials to be as open as possible. If you’d like to see how it works there are several code challenges online. For those you do need to create an account, but it saves your work between visits.

CompSci.rocks Newsletter

Want to stay in touch and keep up to date with the latest posts @ CompSci.rocks?

Leave a Reply

Your email address will not be published. Required fields are marked *