Friday, May 18, 2012

Very small programs to improve programming skills?


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.


Source: Tips4all

11 comments:

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

    Other references:


    Coding Dojo KataCatalog
    CodingKata.org

    ReplyDelete
  2. 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.

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

    ReplyDelete
  4. 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:


    Read in the file
    Create a collection of words and their occurrences
    Create a collection of anagrams
    Create a collection of words and the positions in which they occur (line#, word position)
    Develop statistics on the words in the file - meaning - treating each word as an individual - which words occur before it and after it.
    Remove all of the white space from the file
    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:


    Download the data
    Parse through the data and turn the tabular data into a CSV file
    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

    ReplyDelete
  5. 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.

    ReplyDelete
  6. 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.

    ReplyDelete
  7. 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.

    ReplyDelete
  8. 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.]

    ReplyDelete
  9. 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.

    ReplyDelete
  10. 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

    ReplyDelete
  11. 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.

    ReplyDelete