Bottiger.com main RSS feed

Color Cubes Puzzle - Solved in Ruby

Do you know this puzzle? The idea is that you must place all the cubes in the container so that one of each color is showing on all 4 sides. A very simple problem, but since every dice can be rotated in 24 different ways (yes, not six), there are 24^4 = 331776 different possibilities. Admittedly, the permutation of the dice doesn’t matter (reduces the number with a factor of 4! = 24), and the orientation of all the dice together doesn’t matter either (there’s no up/down/left/right) which means we can reduce the number by another factor of 4.

This means there are approximately (24^4)/(4!*4) = 3456 ways to put the cubes inside the box. This may be reduced a bit further, but I think it’s a good approximation.

Well, after giving up on it last night I decided to try let my computer solve it, and because 331776 isn’t that big a simple brute force was enough.

I wrote my little solver in ruby, and it took me a couple of hours to get it right—or rather, almost right. But what really puzzles me is the solutions. They are correct, but I would expect at least 4!*4 since I’m just doing a plain brute force which would see all the different permutations (4!) and rotations (4) as different solutions. But how many did I find? Not 4!*4, not 4!, not 4 but 8. Why 8? I have no idea, but they work :) (hey! if you have any idea, please contact me)

“The script I used can be found he…

Read the rest

Dynamic content on static pages through AJAX

Until today I had a problem. Because I have a slow server, some many-to-many relationships in my code design, and some pretty heavy SQL querys some pages here on bottiger.com can be a bit slow to generate. Of course the solution to that problem isn’t buying a better server but do some caching.

Since you don’t see any dynamic content on most of my pages you may think that I would be able to do some page caching for the best result, but unfortunately that’s not the case. I actually do have some dynamic content, though it’s not much :) When I log in a page looks like this:

!

As you already know Rails has three methods of caching . I was forced to rely on fragment caching which in my opinion is a mess, since you have to cache both the view and the controller. I read many creative solutions to this, like storing the content in a cookie and have a javascript display it, but I think the only decent solution is to provide the dynamic content through an AJAX request. Normally AJAX isn’t a good solution since the user needs to have javascript enabled, and there’s always a small delay on AJAX calls. But since the only victim is me I decided to implement it. If you google on it you wont find much, since …

Read the rest

Google error message

I just had to do one last search query before I went to bed—and then I got this:

Wikipedia says the following about it :

The suggestion that the user’s computer may be infected is often incorrect.[citation needed] The screen was first reported in 2005 and was a response to the heavy use of Google by Search Engine Optimisation companies to check on ranks of sites they were optimising. The message may also be triggered by high volumes of different searches from a single IP address. The block is removed after a day.[citation needed]

I case you are wondering about what I googled the answer is pretty boring, I just wanted to know when to set my alarm clock :)

Personally I don’t really know what to say about it other than: strange

My 1337 mail

I know this is dump, unimportant and properly only interests me. Some days ago my gmail reached a very important milestone. I’m not talking about IMAP, gmail 2.0 or something like that (hey, I’m using Opera and properly wont get those gmail 2.0 features before 2009).

No, what happened was much cooler :) My gmail reached 1337 MB of mails, which in my opinion proves that gmail is 1337. Actually, today it’s more that 1337 ;)

It actually surprised me that I only could find one and a half writing about the same.

HTML 4.01 CSS Rails Powered MySQL Powered Unicode The GIMP Creative Commons License