Browse Category: programming

Einstein’s Riddle – A Complete Solution With Illustrations

If you haven’t heard about this riddle before then you should try solve it yourself first. It’s a lot easier than you think. Most web sites post it with huge notices that Einstein himself said that 98% of the population would not be able to solve it. Well, this could have been true in his time, since about 98% of the population would not have a chance to read the riddle in a first place, but now with the power of the interwebbies you can read and solve it too. It’s not really hard, if I could do it in under 15 minutes – so could anyone else.

I am posting the rules the way I found them on the internet – this way you can get hyped up about 2% vs. 98%.



There are no tricks, just pure logic, so good luck and don’t give up.

1. In a street there are five houses, painted five different colours.
2. In each house lives a person of different nationality
3. These five homeowners each drink a different kind of beverage, smoke different brand of cigar and keep a different pet.



1. The Brit lives in a red house.
2. The Swede keeps dogs as pets.
3. The Dane drinks tea.
4. The Green house is next to, and on the left of the White house.
5. The owner of the Green house drinks coffee.
6. The person who smokes Pall Mall rears birds.
7. The owner of the Yellow house smokes Dunhill.
8. The man living in the centre house drinks milk.
9. The Norwegian lives in the first house.
10. The man who smokes Blends lives next to the one who keeps cats.
11. The man who keeps horses lives next to the man who smokes Dunhill.
12. The man who smokes Blue Master drinks beer.
13. The German smokes Prince.
14. The Norwegian lives next to the blue house.
15. The man who smokes Blends has a neighbour who drinks water.

The solution is under the cut. I encourage you (again!) to try and solve it yourself before you look there.

Continue Reading

Char Array to String in VB.NET 2.0

You will be surprised, but the obvious

Dim arrChars(10) As Char
Dim strString As String
strString = "ABCDEFGHIK"
arrChars = strString.ToCharArray
strString = arrChars.ToString

Will not yield the same string as there was before. It will, rather, return “Char[]” response. To get your string back from Char Array (at least in VB.NET 2.0) you will need to call CStr on array:

Dim arrChars(10) As Char
Dim strString As String
strString = "ABCDEFGHIK"
arrChars = strString.ToCharArray
strString = Cstr(arrChars)

Funny, isn’t it? And totally counter-intuitive 🙂

Useful Language-Changing JavaScript

Recently I had to quickly make a copy of the same web site iin a different language. Instead of coming up with complicated solutions (the web site isn’t that big and the second language was long overdue) I decided to copy the contents into a subdirectory and just substitute the contents in English with the same in Spanish.

The thought behind was that I can alternate between each page using simple javascript routine. So there I have in English, same thing in Spanish. Same pages are named the same, so it’s and – otherwise the script it useless.

The function is fairly simple:

function langChange() {
var pt = location.pathname;
var hs =;

if (pt.length < 4) {
newloc = ‘http://’ + hs + ‘/sp/’;
} else {
if (pt.substring(0, 4) == ‘/sp/’) {
newloc = ‘http://’ + hs + ‘/’ + pt.substring(4);
} else {
newloc = ‘http://’ + hs + ‘/sp’ + pt;

Pretty universal, works everywhere. Set in as an onclick() event for your language changing butn and you’re good to go.

P.S. If you have much faith in Javascript – feel free to add ajax call to database for current page to figure out the counterpart in a different language.