Thursday, October 11, 2012

Forehead Numbers Brain Teaser of Khan Academy

Today I remembered a little brainteaser I saw on Khan Academy quite a while back:  Khan Academy Link or Youtube Link

What surprises me though is that people still seem to think that there are values for which this can not be solved. My conjecture is that it CAN be solved for all 3-tuples of numbers provided that the participants know that they are unique.

I would recommend seeing the teaser and understanding the logic behind it before reading further.

3 years ago, when I first saw this, I posted a reply on Youtube describing the same 'game' from the perspective of a player who sees 15 and 11. For the sake of simplicity we'll call the player with 15 A and the one with 11 on his forehead C. Therefore the game is described from the perspective of B:
A-figures out his number (15)
B-figures out his number also
C-figures out his number as well (11)

The question then is, what is B's number (obviously it's either 26 or 4 but which one)?

I'm still not going to give the answer, but what I'm going to do is explain it on a particular 3-tuple which somebody on Khan Academy says it's impimpossibleimpossibleossible: numbers 5 7 and 12.
Let's presume they are again named A B and C respectively, A starts.
A sees 7 and 12 therefore he can be either 5 or 19 (sum), since he doesn't know he passes.
B sees 5 and 12 therefore he can be either 7 or 17, doesn't know => passes
C sees 5 and 7, he can be 12 sure, but since he's a PERFECT LOGICIAN, he'll think what if he was 2 (the difference).

Let's see the game unfolding in C's mind, when he presumes that he's 2:
Numbers: 5 7 and 2
A - can be 5 or 9 - pass
B - can be 7 OR 3 - now B can presume that he's 3.
So, again, this is all unfolding in C's mind, B would've seen a 5 (A) and a 2 (what C thinks he might have) and there fore would've thought that he was 3. Then, in B's mind the game would've unfolded like this:
Numbers: 5 3 and 2
A - can be 5 or 1, so, like in the previous assumptions he can think what would've happen if he was one
Remember, just to keep track, we're explaining what C thinks of what B thinks of what A would think and I'm being dead serious about what I'm writing (even my head's starting to hurt).
So from A's mind:
Numbers 1 3 and 2
Now notice that we reach a solvable position: B can figure out his number, since he knows the numbers are unique (he can't be also 1). So again, from A's mind in B's mind in C's mind:
A - can be 5 or 1 - pass
B - can only be 3 (remember, A is 1 in this scenario) therefore he SHOULD know his number.

BUT! B said pass, which tells A that he can not be 1, therefore he must be 5 (if B was 3 and C was 2)

Now, coming back out of the mind of B from the mind of C, so back in our initial configuration (5 7 12)
C can not deduce his number so he passes and now we go onto the second round:
A passes
So now C thinks again, if he 2, B would've thought he was either 3 or 7 and furthermore, B would think that since A said pass, he can NOT be 3 (by the previous logic) therefore he's 7
But B passes what does this mean? it means that C is not 2, he's 12
So now C know's that he's 12 and he can safely say his number and receive a bag of kudos for being so smart (well not really).

So in the end, the game unfolds like this:
A = 5, B = 7, C = 12
A - pass
B - pass
C - pass

A - pass
B - pass
C - figures out he's 12

And then the other figure out their numbers as well - this is pretty trivial considering they are perfect logicians they can be either one of two options, so:

A - figures his number, 5
B - figures his number also, 7

If you managed to follow what happened then congrats! To be honest I have a hard time following, so it might be helpful to take a piece of paper in case you're struggling with the recursive nature of their thinking.
What I find it interesting is how much this resembles Euclid's algorithm for computing the GCD between two numbers. From what I can figure out, the game always ends no matter what numbers you choose - eventually they will presume that they are the smaller of the numbers  that they can be and will therefore reach a stage in which the "uniqueness" rule kicks in.

I'm also thinking what would happen if instead of having 2 possible options (sum and difference) we choose any number of functions that can be performed on two numbers. So say we have a game in which a player can be the sum, difference or the integral part of the average (integral part so that we only have natural numbers) of the other two. Also I'm wondering if using this the game can be extended to arbitrary numbers of players.

Thanks for reading :P

Sunday, September 16, 2012

Qyoto - C# bindings for Qt installation

I have recently taken an interest in C# and have been looking for a GUI toolkit to use. For development, I use MonoDevelop under Kubuntu. There are a few options, the three major ones seem to be Gtk#, Winforms and Qyoto. For me, Qyoto seems like a very good option especially since I have bit of a background using Qt with C++.

I haven't seen a lot of documentation online and if there is, it's a bit outdated. Therefore I have decided to write down my experience with the latest version it.

First of all I would recommend checking out the project's webpage on kde techbased:

Now for installing, I strongly recommend you install both Qyoto AND Smoke (one of it's deps) from source. I've had problems trying to compile Qyoto using Ubuntu's packaged version of Smoke - so make sure that it's uninstalled first. You can download the git repos from here:
First install smokegen, then smokeqt and finally install assemblygen (from If you're unfamiliar with cmake, read below.

All of them use cmake so the build procedure is the same.
To install for example smokegen, clone the git repo (source) and then:
cd smokegen
mkdir build
cd build
cmake ../
// if cmake complains about deps, install them (qt4, phonon, mono, etc) and rerun cmake ../)
make install

If all has gone well, launch MonoDevelop, create a new Empty C# Project and add the qyoto-qtcore and qyoto-qtgui references. You'll notice that are many more, but for now these will suffice. Now the fun can begin.

Remember that the Main(String[]) function should look like:
new QApplication();
(new MainWindow()).Show(); // this is the custom class

Wednesday, May 16, 2012


Hello again, after quite some time, I decided again to write some of my thoughts on my little corner of the internet. The topics I'll write about are consciousness and intelligence along with bits and bobs I've read in my past time. Finally I'll describe a thought that came to me yesterday regarding the Halting Problem and if somebody (not "something") could solve it.

I should start with the idea of self-consciousness and how it could be described. The starting point for this, one could say, is the film "The Prestige". The film poses one interesting question, that is, "if I could copy all of the molecules in my body (in effect, perfect cloning) would there be any distinction between me and my clone?"
From the outside, of course, not. But! internally, there should still be the concept of a me and my clone.
My opinion is that there isn't such a concept. Think of it this way: let's say I have two pods, one of them painted red and one of them painted blue. Initially, both are empty. I enter the red pod, some "magic" happens and then my identical copy appears in the blue pod (notice that there isn't a strict need for shut doors or anything, so the whole process could be in plain sight). Now, one might argue that the "original" me is the one located in the red pod. But! What if the pods performed teleportation at the same time? "I" should then notice that somehow "I" ended up in the blue pod and then "I" would have to convince everyone of that. But what would my clone's perspective be? What if each time, the person in the blue pod, after the "magic" is completed, gets killed (which is what happens in the film). Who gets killed? Can even "I" know which is which?

Here's another thought: what if each time you go to sleep, a mage clones you replaces "you" with the clone and then kills "you" (notice that the first "you" is without quotes). Would 'you' be able to tell the difference when 'you' wake up? Probably no. The reason I used this "sleep" example is because that is a period when you lose consciousness. But here's another example that goes beyond sleep. What if the whole "mage that clones and replaces you" happens every plank-second or every individual quanta of time? Of course this would be physically impossible, but it sort of illustrates the point that there really is no such thing as self-consciousness.

Random ending:
Just a "documentary" I found, quite surprising graphics. Only agree with it until the gives that formula about consciousness, but in any case, it's pretty interesting considering the author, "Athene" (I was stunned when I googled him!)

Monday, March 28, 2011

Sabayon: the cutest, free Operating System

Long gone are the days of meddling w/ the frame buffer in Debian. Today, I've settled on a Gentoo-based distribution called Sabayon.

Disclaimer: this post does in no regards say that a distribution is better than any other; I'm not looking for a flame-war, I'm just stating my own personal opinion on what lead me to use the distro I use today.

It's true that when I used Ubuntu I didn't have the knowledge I have now, but it felt to me like compiling (eg. pulling all of the dependencies for a package was quite a hard thing to do, since the source packages were separate), that was the reason why I starting looking for an alternative. Of course I came across Gentoo, which is basically a compiloaddict. The problem with Gentoo was that in order to compile big packages, openoffice (before it became "libre"), kde, wine, firefox, etc, you needed time and a lot of CPU cycles. So although I felt that Gentoo came really close to what I wanted in a distro: few default packages, up-to-date, complete control over the system eg. the ability to customize everything, easily, etc; it simply wasn't worth all the wait for them (the packages) to compile. Also Gentoo didn't work out of the box, which although I didn't have no complaint over was still an extra step in making a fully functional system.

A lot of the distros I tried satisfied many, but not all of what I wanted:

Fedora and SuSE for example were packed with new packages, worked out of the box, but they felt bloated as they had a lot of packages installed by default. Many of them I had no interest in (bluetooth manager), but others such as SELinux started automatically and that meant reading documentation about how it worked and how to configure it.

Slackware on the other hand, although seemed good at first, didn't supply new packages.

So, after looking on for my next distro to try out, I came across Sabayon:
Sabayon Linux is a Gentoo-based distribution which follows the works-out-of-the-box philosophy, aiming to give the user a wide number of applications that are ready for use and a self-configured operating system. Sabayon offers the user an easy-to-use workspace with a captivating look, good hardware detection and a large number of up-to-date software packages installed by default, with additional software available from a repository. Sabayon is available in several flavors featuring respectively the KDE, GNOME, LXDE, Xfce and Enlightenment desktop environments.
Wait... works-out-of-the-box, up-to-date software, Gentoo-based? Yes, It was all that I needed... it was perfect
Since then I've been happily using it and I would gladly recommend it to anyone who knows the difference between "du" and "df".

Now to talk about why I think Sabayon is awesome:
1. A lot of precompiled packages, that are fairly up-to-date, but more importantly not installed by default.
2. Gentoo-based: with a little bit of care and attention you can emerge the latest packages with no problems
3. Looks awesome! KDE 4.6.1 ftw, and I think the update window was of about one week after the official release, so not a lot of waiting.
4. works out of the box, just slam the livedvd in and you're set to go!

The first two points are the most important for me and even though you may find a bit outdated packages in the repository (binary packages), as was the case for dev-util/qt-creator-1.3.1 , you can simply emerge the latest version. You have to be careful about NOT emerging the dependencies also (use the binary packages to satisfy them). That way when the new version is available in the repo, you simply unmerge it and install it normally.

So far I've got nothing to complain about, the community's great, they've got forum, wiki, bugtracker, irc, mailing lists etc, so you'll never be short of finding help if you have a problem. It doesn't have a lot of 'distro'-specific packages (coubuntugh cough) and it works! it simply works great and it allows you to modify whatever you please. Just... don't go cursing if you... "accidentally your xorg" ^_^">

Wednesday, March 9, 2011

Not "red pill OR blue pill" but more like "red pill and MIGHT've been blue pill"

In my previous article I covered, from my point of view, the subject of free will. After rereading it, I became aware of some of the logic faults it contained and decided to give the matter a bit more thought.

This concept is always bugging me because it seems that we are constantly constrained by the decisions we "make". Somebody even suggested that my logic basically implies destiny, well I don't believe in destiny, because of the effects of quantum mechanics. Still, I came to realize that we are not far from the concept of predeterminism.

Now I am an atheist and that means that I don't believe in concepts like "souls"; also, I consider human beings and living organisms in general to be nothing more than extremely complex systems but which are undoubtedly ruled by both the cause and effect principle and in some cases random outcomes. In other words I don't see the fundamental difference between a human and something as a bunch of rocks reacting to the changes in environment, and also at the same time, influencing some changes on their own (except of course for the level of complexity). This I admit might be a weak link in my argument.

Now let's look at a simple event A that occurs in the present and then determines a event in the future (event B).
If we know what the effects for event A are we can predict event be occurring in the future. Now let's say event A is something you hear; event B is something you do. Now since B is caused by A, we can not say B was done out of free will.

One might argue that we can not predict with certainty anything. True, but when are we not at the mercy of a quantum outcome? Consider the example of choosing between two colors: red or blue (no... of course it has nothing to do with the title, no...). Your neurons start firing and, for the sake of simplicity let's say that there is one (let's call it P) that is connected to two other neurons: R and B (or "B and R" if you like, depends on your taste). If P fires a signal to R then you choose red, to B, you choose blue. The neuron that P will fire a signal to is influenced by quantum mechanics (random). But notice how your decision isn't actually made by "you" but by the outcome of that random event.

Ok, as with a lot of what I write: first I the idea pops into my head, I think about it, I write about it, then I decide to google it and see many more who had the same idea way before me. Still, it feels good knowing that I came to the same conclusions without knowing about those people.
In regards to this post, the subject I found out is called Incompatibilism it's also linked to Hard determinism as well. a

Still, I'm not done talking about this free will thing, as will see in a future post (sorry, had to make this reference to determinism)

Sunday, March 14, 2010

Red pill or blue pill

I remembered last night a topic that I forgot to cover here, more precisely the subject of free will.

It occurred to me a while back, when somebody mentioned the fact that since our minds are defined by the synapses our neurons make and since the synapses are to some extent *semi-random events we can't have free will.
*semi-random as in predictable to a certain degree, like 95% chances that will happen 4% chances this will happen and 1% complete randomness.

The way I see it, quite the opposite's true. But first, let me get a thing straight: here, "free will" means one's ability to make decisions "as wished", or in other words, nobody should be able to tell with complete certainty what decision one will make in any given situation. Note that I'm NOT referring to free will as the right to do anything we wish.

If we consider the semi-randomness of our thoughts, then free will is possible. If however, our brains behave in classical terms, as in governed by the 'cause-effect' law, then we are deterministic. You could then think that a human brain could be simulated by a Touring Machine (more simply, it could be simulated by a computer). But a Touring Machine is defined as a set of states and a law of transition that transforms one state into another. It can not have, by definition, free will.

Now presume we act in the same way and it's pretty easy to see why we would do this if you believe in evolution: we'll always choose the option which gives us the greatest benefits at the moment of decision. You may quickly dismay that by arguing that people can do sacrifices, but if you think about it, the comfort they gain knowing they made some sacrifice and that a loved one / friend will be happy is greater than if they wouldn't have done nothing (in that case, guilt would be the main cause of discomfort).

If we also think our neurons of acting according to strict rules; as in if neurons A and B are connected to C and a rule such as if A and B don't fire then C doesn't fire also; A fires B doesn't fire then C fires; A doesn't fire B fires then C fires; A and B both fire then C doesn't fire (C acts as an "exclusive or" for A and B). Note that this is just an example of a rule, in reality they are probably way more complex but still remain strict.

Based on these two, evolution and strict neuron-firing rules, one can conclude that we behave deterministically. This means that there can exist a person / entity which can figure out what we'll do in any situation (presume it has complete knowledge of the way our brain is wired), then this entity can predict what course of action we will take in any circumstances. Then, because our course of action becomes known beforehand, we cannot have free will.

Now as I've said, this argument rests on basically on two assumptions, that we always chose the most profitable alternative and that our neurons don't fire at random or semi-random, because if they would, there may be the possibility of an alternative choice which isn't considered by our mind, and that missed alternative is a random one, thus the first assumption will yield different results, even if our brains are in the same 'states'.

This was a little far-fetched scenario, because not even I don't think the second assumption is true.
But here comes the shocker:
Even if our neurons fire in semi-random patterns, it's true that nobody will be able to predict how we will act. But our feeling that we are in charge of our actions becomes an illusion. In fact I've failed to find an example in which this is NOT one.

Let's presume you have a choice of choosing one of two pills, one blue, one red (this doesn't have to do anything with the Matrix movie). What happens when you take the decision? Your neurons start firing and by a random or semi-random chance you get to pick blue (even if my first assumption is true, the decision will be influenced by some neuron randomness). Now truth be told, you could have just as well picked the red one. So the problem is that you didn't pick blue because you wanted but because chance made you pick it. This has led me to believe that free will is just an illusion, and that we are forever confined in our minds, just spectators to what our sense organs tell us is happening around us, with no power to change the inevitable course of randomness.

Wowzer, now that was bit of a fine ending if you ask me. In anycase, that's the conclusion I've came to, hopefully, somebody will prove me wrong, but until then I can only say that I'm just going to sit back and see what this body of mine will do heh.

Tuesday, December 22, 2009

The Atheist's Riddle - attempt to solve

Longtime no write... oh well, here I go again:
This time, it's about something I read a long time ago and namely The Atheist's Riddle. To put it simply it states that information can only be created by a conscious entity and since DNA is also information (genetic one), it MUST have been created and not spontaneously/randomly appear. Here are two examples of it, the first is the original one I received on an email and that got me thinking, the second one is just another restatement of it I found on the net.
"Messages, languages and coded information never,
ever come from anything else besides a mind.
No one has ever produced a single example of a message 
that did not come from a mind.
Nature can create fascinating patterns - snowflakes,
sand dunes, crystals, stalagmites and stalactites.  Tornados 
and turbulence and cloud formations.
But non-living things cannot create language. They
*cannot* create codes.  Rocks cannot think and they
cannot talk.  And they cannot create information.
And the second:
Proof that DNA was designed by a mind:
1. DNA is not merely a molecule with a pattern; it is a code, a language, and an information storage mechanism. 2. All codes we know the origin of are created by a conscious mind.
3. Therefore DNA was designed by a mind, and language and information are proof of the action of a Superintelligence.

This has kept itself on the back of my mind for I guess around an year since I first received the email with it.
In that time, I came up however with two possible theories to explain it:

My first attempt was based on the interesting property of DNA (and RNA for that matter) that is to replicate. I thought that given the right conditions you can obtain a molecule that is stable and that can interact with other matter around it, creating copies of itself. This consumes work and thus the molecule would probably have to unbind some part of it in order to have energy to make the replication. It could then reform itself to it's complete state by re-assimilating the missing part using some sort of external energy (solar, geothermal, etc).
Problem with this theory is that after you get enough copies of this molecule, nothing happens so then I though that maybe it could sustain modifications and still retain it's properties, then you could have something very similar to RNA.
Still, it requires the chance to have spontaneous creation of the first molecule, but it's pretty decent as a first explanation of the riddle.

My second attempt was a few days ago, when I asked myself "what is information?". The riddle states that
"[rocks] cannot create information". But as it turns out information can spontaneously appear in nature, even more often than you might think about. This is based on a definition of information I came up with:
A region in space that has an entropy value different than the rest of it's surroundings.
Note that I do NOT know if it is a correct definition, but it seems that everything that has a lower/higher entropy contains some sort information.

Oh, I'm assuming you know what entropy is, if not I strongly recommend you look it up on the internet, but in case you prefer to continue reading, entropy is basically a measurement of how much something is disorganized. So, for example a row of soldiers has a lower entropy (is more organized) than a crowd of people.

The key is to note that information in this form occurs very often in nature, take for example a tornado it leaves a mark on the terrain it traversed, it obeys the first law of thermodynamics, as it does work (spins) in order to leave a mark on the ground. That mark is information: information that a tornado passed, it contains maybe the side and speed of it. Now there may be a big step from tornadoes to the creation of life, but I've shown that there nature is capable of producing information. This information could take form in RNA (though I admit it's a big leap) or DNA