Code and Bugs

Coding things

Category: Questions of a Beginner

Well, I’m back

Nearly an year has passed since I last wrote on this blog with a specific plan in mind. There were several articles in the meantime but very few and written because of a moment’s hunch.

I’m back now, even if for a short period of time.

This article is divided into two parts (I’ll try to make them be under 500 words each):

Each of the two parts has a separate page.

Pages: 1 2 3

GTK Custom Drawing and Saving

In one of the previous mentioned homework, I had to draw an image of a neural network on a custom widget and later save said image to file. This post was inspired by this task.

Read the rest of this entry »

Machine Learning

This semester, I took an introductory course to Machine Learning. I learned about id3, version space learning, neural networks, GAs, etc. And I had to some homework using several of those techniques.

Read the rest of this entry »

Programmer’s context switch

Say you are working on one project when someone calls you or sends you a mail asking you to look into another project, either a bug in one of your old projects or problem in his. Although programmers don’t like interruptions, this is a case where you have to do that context switch and return to your project afterwards. So, how to do this efficiently?

Read the rest of this entry »

Craft or art?

One of my teachers once said to some of his students: «Your job is both beautiful and cursed». He was referring to the fact that, in Computer Science, one has to always learn something new while being certain that what he learns will become obsolete in a shorter or longer period of time.

However, this is only a partial reason. At least, for the programming part of Computer Science.

Read the rest of this entry »

New Distribution (part 1)

Since the day Ubuntu Lucid Lynx was released I planned to get a day when I’ll install Arch instead of the old Ubuntu I used. I did this a few days ago or, to say it better, tried to do this. The end result is that I have Lucid on my laptop for this week :)

Read the rest of this entry »


All xkcd‘s fans know the raptor problem: suppose you are standing at the centre of an equilateral triangle with three raptors in the corners, one of them injured (thus going with a slower speed). Knowing the speeds of all entities and the edge of the triangle determine the direction in which you will have to run to maximize your life time.

Read the rest of this entry »

GCC Array

While doing one homework I’ve observed one little known fact about gcc: declaring dynamic arrays as normal arays (like int a[n])

Read the rest of this entry »


Let’s say we have two ships arranged on a line. Both ships are sailing with the same speed. However, while the first one is always going in a perpendicular direction to the line initially connecting the ships, the second one will always try to go towards the first.

We are asked to determine the distance between the ships after enough time has passed.

Read the rest of this entry »


Yet another puzzle solved in Haskell. This time we have a raytracing problem. A simplified version but, nonetheless, hard to do in a functional way. At least in a non-monadic fashion.

Enough talk. Let’s see the problem: suppose we have a box with size n by m. Inside the box we have some light sensors – some cells which are initially black and which will turn to another colour as soon as one light ray comes very close to them. The sensors are placed at all integer coordinates in the box (assuming that the maximum allowed coordinates are n and m). Their sensitivity is chosen such that a cell is active only if the ray passes the point where the sensor is placed. Filling the box with sensors, we would like to obtain a picture of their state after several light sources are placed in the box.

Read the rest of this entry »


Get every new post delivered to your Inbox.