Very small programs to improve programming skills?

JavaC

Java Problem Overview


I realize that to become a better programmer, you need to program! So obviously the more practice, the better you become.

My problem is this. I am currently in university, and I find my course load is a bit daunting, and I don't have a lot of free time. I don't think I could really take on a big project, particularly I don't think I would have to motivation to see it through, it would be easier just for me to keep putting it off in favour of work that is due is school.

But I still want to practice. So I am looking for any resources which have programming challenges which can be completed in a fairly small amount of time. Ideally something i could get done in under 10 hours of work (so just over an hour of work each day), if not smaller.

I have heard of Google Code Jam, but I am not sure the length of the programs it specifies, nor the skill level.

Does anyone have suggestions? Even perhaps a compendium of tutorials for different functions might be useful. For example, a tutorial on file IO would be worthwhile (if I didn't already know it), even though it can be a fairly small topic.

Java Solutions


Solution 1 - Java

You should look into code katas, they do exactly what you are talking about. Short exercises that are designed to perfect your coding/thinking abilities.

Other references:

  1. http://kata.coderdojo.com/wiki/Overview_of_Learning_Resources

Solution 2 - Java

Project Euler has some math/number related problems that are very interesting and ranged from easy to very challenging. You can pick your language of choice and submit only the solution (a large integer number). After you submitted the correct solution, you have access to a forum/comment page where others posted their comments and solutions.

Solution 3 - Java

From experience I recommend finding a task that you do repetitively and turning it into a program. I also recommend, seriously, re-invent the wheel in order to get practice with programming. Don't let people tell you to not do something just because it exists already. If you don't know how it works, try to write it yourself.

I don't exactly know what programming level you are on, but don't try to do anything too crazy off the bat, that is just a demotivator (such as trying to write a game for the PS3).

If you already can navigate your way around with IO, then you should try to really learn how to use Collections effectively. I think one of the best practice assignments I have ever done was rewriting the Java TreeMap Class. It was a huge challenge and I learned a lot by doing it.


Here are some suggestions for practice assignments:

Take a text file that has a fair amount of information in it, grab anything, you can get something from here if you'd like: <http://www.gutenberg.org/> and make a program that will do the following:

  1. Read in the file
  2. Create a collection of words and their occurrences
  3. Create a collection of anagrams
  4. Create a collection of words and the positions in which they occur (line#, word position)
  5. Develop statistics on the words in the file - meaning - treating each word as an individual - which words occur before it and after it.
  6. Remove all of the white space from the file
  7. Write all of the above data to their own files

One of my favorite things to do is mess with web data, go to a polling website, find a page that has poll data in a tabular form and do the following:

  1. Download the data
  2. Parse through the data and turn the tabular data into a CSV file
  3. Open it in excel without error

Or just look for any site and extract data from it, just make sure the site is robot friendly <http://www.robotstxt.org/>;, you don't want any one site to feel like it is under attack. Most of the time though this isn't normally a problem because if you read the site's terms of use it clearly states you are allowed to download 1 copy of whatever it is you are viewing so long as you don't intend to sell it. Of course this changes for every site.


Go to a website and get all of the links off of the page programmatically.


Here is a fun one, the Susan Program (I don't remember why it is named Susan) which I initially wrote using a C program and two Bourne shell scripts in a Unix environment. The idea in this program is to fork 4 child processes and give them each a task like so:

Child 1: Reads in a file, creates a dictionary of each word and its position in the file, this is outputted to a file.

Child 2: Takes Child 1's output and reconstructs the document, this is outputted to a file.

Child 3: Takes Child 2's output and does what child 1 did again

Child 4: Takes Child 3's output and does what child 2 did again

The goal here is to have an exact replica of the original file once Child 4 outputs it. This is challenging and somewhat pointless, but the point of this exercise is to get the practice.

In your case, don't feel that you need to use different threads for this, you can just use a single program with two different functions and just call them in order.


Again, not sure if you are at this level yet, but try to replace any "for" or "foreach" loop you have in your program with recursion, just as practice. Recursion is a pain in the butt, but it is valuable to know and understand.

These are some suggestions which I think will really help you sharpen your skills.

Enjoy

Solution 4 - Java

I like SPOJ and Project Euler to take quick programming challenges and exercises.

Solution 5 - Java

Code Jam is a good programming contest, although, as you mentioned, most of the problems there aren't for beginners.

There's a good selection of problems from past topcoder algorithm competitions. (They are held ~2 times a month for almost 10 years already, so there're quite a lot.)
Difficulty range from very simple (but still interesting) problems in the 2nd division to very hard. Additionally, there're editorials with solutions and live environment where you can submit and test your code. You can also learn from submissions by other people.

Check the problem listing.
Another advantage of topcoder is the regular online contests they hold. I find that competing against other people in realtime is a great boost for motivation.

There're many more problem archives, like SPOJ, UVA and Timus, although they rarely provide solutions or even hints.

Solution 6 - Java

http://codegolf.stackexchange.com might have some programming challenges to your liking. A lot of the answers on that site are golfed (they implement the program in the least number of characters) but there are definitely some interesting examples to learn from.

Solution 7 - Java

Try enrolling on any IT course on the following websites:

These websites offer free educational IT programs from prestigious schools wherein there are lot of challenging exercises to sharpen your programming skills. I've learned to program percolation, pattern recognition, bouncing ball and so many more interesting things because of this. You will upload your program upon completion of the exercises and you will be graded accordingly (basically your progam will be checked).

At the end of each course, you will even receive a certificate of completion. Cool Right?

Solution 8 - Java

It depends of the language, but in the past http://rubyquiz.com and http://pythonchallenge.com did great for me, also you can join to an open source initiative because usually helps to give you better code review chances.

Solution 9 - Java

I've always thought that practicing with sample interview questions was a great way to sharpen one's skills and get exposed to types of problems that you normally wouldn't solve. Plus, if you're going to be looking for a job it helps you even more.

Here's a pretty simple one that I did for fun the other day:

> Write a routine to print the numbers 1 > to 100 and back to 1 again without > using any loops.

Glassdoor.com has a lot of good interview question submitted by people who actually got them in an interview.

Solution 10 - Java

Since you are in University and looking to improve your coding skills the hard-copy book Cracking the Coding Interview might be a good fit for you. It's got great general programming questions and tidbits about interviewing with some of the best companies in tech. Not only are there great questions, but there are decent problem breakdowns as well.

[Disclosure: I own the book but otherwise have no association to it.]

Solution 11 - Java

If you like programming and want to improve your programmer skills, you must try cocode.co. It's a social young site, similar to StackOverflow but based on posting and solving programming challenges, instead of asking and answering questions. From very easy challenges to very hard ones.

http://cocode.co

Solution 12 - Java

You can try to solve ACM problems. There are thousands of problems there and you can find the difficulty level so you can choose which problems to do first. The offcial site for this is:

http://uva.onlinejudge.org/. You can learn more there.

regards arefin

Solution 13 - Java

It may seem a little obvious, but I've noticed a real boost in my regular-expressions skills lately just from answering regex questions on Stack Overflow. Teaching forces you to break down problems into easily explainable pieces, and will also guide your research on those occasions where you know most, but not quite all, of a solution.

I suggest finding a topic you're already somewhat proficient in, since this type of thing isn't so good as a beginners' tutorial. Search SO for questions tagged with that topic and try to figure out the answers. Don't just code them in your head; go ahead and write them out, test them, and explain them. If you're not sure your answer is correct, just write it without posting it.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBlackbinaryView Question on Stackoverflow
Solution 1 - JavaNixView Answer on Stackoverflow
Solution 2 - JavaschnaaderView Answer on Stackoverflow
Solution 3 - JavadyslexicanabokoView Answer on Stackoverflow
Solution 4 - JavaFábio PerezView Answer on Stackoverflow
Solution 5 - JavaNikita RybakView Answer on Stackoverflow
Solution 6 - JavaKevin StrickerView Answer on Stackoverflow
Solution 7 - JavanewbieView Answer on Stackoverflow
Solution 8 - JavaMexicanHackerView Answer on Stackoverflow
Solution 9 - JavaZach BView Answer on Stackoverflow
Solution 10 - JavaiwalkbarefootView Answer on Stackoverflow
Solution 11 - JavasgmondaView Answer on Stackoverflow
Solution 12 - JavastinepikeView Answer on Stackoverflow
Solution 13 - JavaJustin MorganView Answer on Stackoverflow