Very small programs to improve programming skills? [closed]

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.


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

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.


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


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