Posts tagged ‘C++’


Project Euler

I’ve become an active member of Project Euler (PE) again. Project Euler ( is a collection of (around 300 or so) mathematical and programmatical problems. I’m not sure when I started the first time, but it’s been a couple of years, I think. Now I’m back again with a bit more knowledge and feeling a bit more comfortable with programming, several programming and math courses later.

When I first joined, I was mostly only comfortable with Java as my programming language of choice, but I’m very interested in learning to program comfortably in C for a few reasons:

  • It is the traditional language in Unix/Linux applications.
  • I like GNU/Linux and Free and Open-Source Software.
  • It is a lot faster than Java… but still has very similar syntax!
  • I like handling pointers for some reason. I feel like I’m much more in contact with the data as I have full control of everything. It’s just so gratifying to get Segmentation Fault after Segmentation Fault and then, after some debugging and messing around with my pointers, finally getting the sought output from the program.

I don’t believe it’s mandatory to join Project Euler to take part in the problems, but I recommend you sign up for an account, because if you do:

  • you can provide answers to the problems and Project Euler will keep track of the problems you’ve solved.
  • you may participate in the forum thread for a particular problem upon solving it, allowing you to discuss your solution with fellow members. (It’s incredible to find solutions written in the J and K programming languages, which afford extremely concise programming.) Note that only relatively recent forum threads are open to new posts, but all threads are open to read (upon solving the corresponding problem, as I already mentioned).

Project Euler is a very fine tool to learn a programming language. If you’re not a programmer by profession and you don’t really have any software needs that aren’t fulfilled, Project Euler provides you with a great environment to experiment with a programming language’s syntax and libraries with problems and tasks to solve and complete.

My goal right now is to solve as many problems as I can using only the standard libraries in the GNU Library (glibc), namely stdlib, stdio and occasionally string (so far I’ve used string only for the strlen function, which I felt was unnecessary to write myself). It’s going pretty well, and it’s kind of fun to have to figure out solutions on your own instead of relying on already-written functions to do the job for you.

Some of the problems at PE can be solved only with the help of pen and paper, but most of them require up to thousands of iterations to find the solution and isn’t feasible without some computational aid. However, according to the site’s FAQ section, which they call “About”, all the problems are designed in a way that a well-constructed algorithm should take no more than 1 minute to output the solution to the problem. I’m very proud of C. Most problems finish in milliseconds, even on the super-slow laptop I use sometimes.


It feels good to be a winner

Yesterday was this year’s Uniaden. A fair held in and closely around the Universum building at UmeĆ„ University. The fair has booth spots for many companies that come and talk students who attend the fair to find out where they might end up working one day. It’s a mutual opportunity for both the companies and the students because the companies can make themselves known and attract talented people to work for them, and the students (well at least some) might create connections with the job market and maybe even get job offers.

Just prior to this year’s fair, Ardendo, which I think is a sub branch of Vizrt sent out an e-mail to most of the computing engineers at the university with a challenge and a chance to win a 320 GB hard disk drive.

The entire challenge was contained in a single source code file written in C++. It was a program that would output an image file, if all the bugs in the program were sorted out. I’m not extremely used to C, and I’ve never used C++, but this code was fairly similar to C, so I wasn’t too lost. I managed to at least fix all bugs that I could see, and I got an image file which had an inscribed time stamp and symbol. All participants were to write down this secret time stamp and symbol along with their name and e-mail on a piece of paper and hand it to the folks at the Ardendo booth.

On the day of the fair, I went there, handed in my contribution and had a good chat with the folks there. For the record, Ardendo seems to be a nice place of work. They do some interesting things (create software solutions for professional television broadcasting stations), and they seemed to think that I’d be a good candidate to work there once I’ve finished my education and given my interests and current knowledge.

When the time came to draw the winner of the competition, they took all the pieces of paper, which were different in size, shape and color because everybody wrote it down on their own piece of paper, and indexed them with numbers. The numbers were then mirrored on a different set of indentical pieces of paper, and the winner was drawn from that set. There were about 6 or 7 people who entered the competition.

It turns out I won!

I couldn’t believe it. And it turns out the drive was 400 GB, and one of those smaller, sleek ones that only need enough power to be powered from the USB cable alone, which is brilliant. It was a happy day.

I should mention I didn’t solve the bugs the way it was probably meant, because if I had, I would appparently have seen yet another hidden “easter-egg” message from the creator of the challenge. If I had solved it correctly, I would also have had a chance in an extra lottery where the prize was a beige cardigan with, I think, the Ardendo logo on it.

I’m glad I won the first lottery.