CodingBat: Java Solutions

For further help with Coding Bat (Java), please check out my books. I am also available for tutoring.

CodingBat is a website containing a couple hundred exercises for the Java and Python programming languages. It is run by Stanford professor Nick Parlante. You may know him from Google’s Python Class or the “Binky Pointer Fun Video.” Last year, he taught Computer Science 101 on Coursera.

CodingBat is a great resource if you’re starting out with programming. It can also serve as an excellent confidence builder if you’re not sure whether to take some computer science classes in college. If you can make your way through that website, you should find a typical first and second course in computer science to be quite manageable. In my case, I used it to supplement CS106A: Programming Methodology, which is hosted at Stanford Engineering Everywhere and Allen B. Downey’s book Think Java.

There are many CodingBat solutions floating around on the Internet already. What I’ve found, though, was that some were quite badly written and rather verbose. I also came across a few instances of macho posturing where people presented solutions that only showed off their alleged brilliance instead of helping others. This includes a recursive solution to a problem that wasn’t even supposed to be solved via recursion. Others used Java functions that negated the purpose of the exercises. I saw one guy posting what he thought to be oh-so smart one-liners. Of course, one could use String.replace() to replace characters in a string, but if you’re supposed to practice loops, you’re only cheating yourself.

I won’t claim that my solutions are the “best” out there. Yet, I do think that my code is well written. I have also made sure to only use the Java functions mentioned on the CodingBat website. CodingBat contains 13 section on Java, with some sections containing up to 30 exercises. Therefore, I will split my solutions over a long series of posts.

For further help with Coding Bat (Java), please check out my books. I am also available for tutoring.

One thought on “CodingBat: Java Solutions

  1. Gordon

    Thanks a million for all your coding bat solutions Gregor. They’ve really been a tremendous help. Your hard work is very much appreciated !


Leave a Reply

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

Spammer prevention; the answer is an integer: * Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.