views:

2964

answers:

10

I am learning C++ currently and am probably at the intermediate level. I am running out of ideas for what to do with my current programming skill. And, as the title puts it I need some practice problems.

ps. maybe the problems can be divided into beginner, intermediate and advanced

+6  A: 

You could try thinking about some of these codekata. Some you can implement others just require thinking. These are not especially C++ oriented, but more general.

Peter Stuifzand
+3  A: 

Try Topcoder. You can skip the competition aspect and just try old problems. The benefit is that you can solve a problem on your own, then look at lots of other solutions in many different languages when you're done.

Bart
+2  A: 

If you just want problems (not C++ specific, but can be done in C++ there is) Programming Challenges They have an online judge as well so you can submit your code and it will tell you if you have the right solution. Be warned though this is meant for people involved in programming competitions so when you submit a solution and the answer is wrong, it will not give you specifics on what the problem is. Having said that these are fun and get you thinking.

Redbaron
+1  A: 

If you're an intermediate programmer, I'd recommend working on projects that involve a lot of code, rather than problems that require only a few functions or files to solve. These are some projects you can try. I think they're simple, but can get more complex depending on how many features you have.

1) Write a web server that uses sockets, parses HTTP, and returns files from the filesystem. You can add more features like caching, gzipping, following rules for certain HTTP headers.

2) Maybe a program to simulate a Bank. You can create classes representing users and accounts. Users can create accounts, deposit, and withdraw money. And you can have some locking to make some there no concurrency issues. And you can create a command line interface or web interface. Maybe add loans with interest or savings accounts.

3) a database where you can create, read, update, and delete data. You can learn design skills about what data structure to use to store you data. And you'll also need commands to interact with data. Maybe you can find a SQL parsing library or write you own.

A good thing about projects (as opposed to small problems) is that you get to learn skills like design, maintainability, readability, scalability. Later on you might move on to another language like Java or C#, but those skills can stay the same.

Chris
+1  A: 

Two of my favorite 'learn a new language' projects are:

  1. Implement Conway's Game of Life (http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life)
  2. Implement a graphical disk usage visualizer (something like http://www.jgoodies.com/freeware/jdiskreport/index.html)

These tasks are good because you have to learn a variety of aspects of the language (file operations, user input, GUI stuff) and they're actually fun and useful so you stay interested.

AndrewR
A: 

I would perhaps look at this in a different way and propose that to really understand and learn a language well is by doing something practical with it - I think that you can gain a real sense of achievement when your see your code being used by other people (and this can encourage you to learn more and do more with your new found skills).

I would perhaps start by looking at as many open source projects as you can - download and look at as much code as you can absorb (it's very good for you). Perhaps you may find a project that sparks some interest, or perhaps you spot a piece of code that just doesn't "look right". However you go about it, there's a wealth of material out there - I think that the best way to go from a mediocre to an competent to an expert developer is by learning from other people and actually getting your hands a little dirty!

Alan
+1  A: 

If you're not afraid of math, you might give Project Euler a try. You can get a general idea of the difficulty of the problem by looking at how many people have solved it, and although for a lot of problems figuring out the math is the biggest challenge, coming up with algorithms and an implementation that won't take a half hour to run becomes important fast.

MovEaxEsp
+1  A: 

I always used to write a Mandelbrot and Julia fractal generator when I first started learning a new platform or framework. Of course, that requires graphics capabilities.

For more basic problems you might try Project Euler which presents problems as challenges. Most problems can be solved in fifteen minutes or so. (Some much quicker if you have infinite precision languages like Python, but I think that is almost cheating). They are generally problems like:

  • find the 10,001st prime,
  • Starting in the top left corner in a 20 by 20 grid, how many routes are there to the bottom right corner?,
  • How many Sundays fell on the first of the month during the twentieth century?,
  • calculate the sum of all the primes below two million, or
  • find the first ten digits of the sum of the following 50 digit numbers.

All problems contain any incidental information you may need, such as definitions of prime, abundant number, amicable pair, et c. Many are trivial to code a solution for, but you need to be a little more clever to have the program finish within the lifetime of the sun. There are message boards to discuss the answers, and lots of questions to go through.

Mark Santesson
A: 

This site has a huge problemset of interesting little challenges. A great way to work on your programming, as well as problem solving skills.

unclerojelio
A: 

Try CodeChef, there you can win prizes too!

Lazer