MMF Object Updates for Unicode

Some of my MMF objects have been updated to make them work in the Unicode version of MMF. This does not mean they support Unicode, it just means that they still run on the Unicode version. In particular, actions where you could type the name of an object and it would interact with it now work again.

The updated objects:

Note that the List & Set Object release is the first since the new List control actions have been added.

Please report any bugs.

Update: The Ini++ object has been updated again to fix a bug with the properties.

X10 Remote Control Config (“X10 UR86E PC Remote Control”)

A while ago I bought a remote control for my media PC. It is OK – it came with a code which made it work for my TV too, but the ‘ShowShifter’ software it came with for the PC was terrible. Not only that, it really wanted me to upgrade. I tried the version it wanted me to upgrade to, and it was just as awful. However, it turned out that software let you change registry keys to change the behaviour.

Of course, this is boring to do by yourself so here is some software, written in Multimedia Fusion, that actually makes this task not annoyingly boring.

Download

I made the play/pause buttons and so forth correspond to the Windows Media Player shortcut keys. By called rundll32.exe you can also make the power button make the computer sleep. Note that to use this you do need the software installed. Overwrite every function which calls ShowShifter and then delete it (don’t uninstall it, for it takes the things you want with it).

ShowShifter really is bad.

The Light Bulb and Tower Problem

A puzzle interview question I was recently asked:

You have two identical light-bulbs. You need to find out how strong they are. There is a 100-floor building and you can drop the light-bulbs out of the window. You know that there is some floor such that it will break, and it will break for all above it, but you don’t know what floor that is. It will never break for anything less than that floor.

Find the method of doing this such that the worst-case is as small as possible.

Obviously it is possible to just start at floor 1 and go up until you find it. The worst case then is 100 drops, which is pretty poor. An improvement on that is to go up every other floor, using the second light-bulb to work out which floor it was when it breaks. That gives a worst case of 51 drops.

This can be generalised to stepping up N floors each time. Then the worst case would be:

This function can easily be minimised by taking its derivative and seeing where it is 0. This method gives N = 10, suggesting you should go up every 10th step. The worst case is floor 99, which takes 19 drops.

But if it took 19 drops worst case, why did we bother starting on floor 10? If we started on floor 19 we wouldn’t make things any worse, and we might make them better. The key is: If the worst case is k drops, the first level to try should be k.

What about after that? Well, we can go up k-1 more levels and still the worst case stays the same – you only need to check out the k-1 levels between the two points if it breaks, giving an overall of k drops.

So on the assumption that the worst case is k, the best method is to:

  1. Try floor k. If it breaks, try the k-1 floors below it, thus there can be at most k drops. Else go to 2.
  2. Try floor k+(k-1). If it breaks, try the k-2 floors below it. Combined with the two drops already done, there can be at most k drops. Else go to 3.
  3. Try floor k+(k-1)+(k-2). If it breaks, try the k-3 floors below it. Combined with the three drops already done, there can be at most k drops. Else to go 4.
  4. And so on

So what should this value of k be? Well it is the least k such that there is some r such that:

That r may as well be zero, so we just need to find the least k such that the sum of the first k integers is greater than 100. Using the formula, that is just:

As k and k+1 are next to each other, this means the answer has to be somewhere around the square root of 200, which is about 14. Indeed, 14 is the least value, as it is easily seen that 13 does not work.

Therefore the floors you should try are:

  • 14, going back to floor 1 if it breaks
  • 27, going back to floor 15 if it breaks
  • 39, going back to floor 28 if it breaks
  • 50, going back to floor 40 if it breaks
  • 60, going back to floor 51 if it breaks
  • 69, going back to floor 61 if it breaks
  • 77, going back to floor 70 if it breaks
  • 84, going back to floor 78 if it breaks
  • 90, going back to floor 85 if it breaks
  • 95, going back to floor 91 if it breaks
  • 99, going back to floor 96 if it breaks
  • 100, although by now you know it must be 100 without trying it.

I’ve written a little Java program (using Multimedia Fusion) to try out the two approaches. Check it out

Download

KenKen Cheat Program

I’ve now written a general KenKen ‘cheat’ program as an exercise in Haskell, with a Multimedia Fusion front-end.

KenKen Combination Finder

KenKen Combination Finder

One thing it required was the ability of the user to specify the shape. Now in essence this reduces down to the ability for numbers to be repeated. For instance, in a straight line of length 3, there must be three unique numbers and so the ‘configuration’ is ‘1,1,1’. (i.e. three numbers appear three times)

A 2-by-2 square on the other hand can have two numbers repeated twice. That is, the configuration can be ‘2,2’. However, you could also have 4 distinct numbers, that is ‘1,1,1,1’ or ‘2,1,1’ as well (one number repeated and then two other numbers). However, the ‘2,1,1’ can be derived from ‘2,2’ others by splitting up one of the twos into ‘1,1’. ‘1,1,1,1’ can be found by applying the same thing to the others.

As another example, ‘2,2,1’ is a derived configuration of ‘4,1’, as the 4 can be split into 2,2.

As an example of two configurations on the same number of squares where one isn’t a derivative of the other, take ‘3,1’ and ‘2,2’. (The latter represents a square and the former does not represent any connected shape.)

You might ask: Given any two configurations of the same shape, will one always be a derivative of the other? The answer is in fact ‘no’. The 6-square ‘U’ shape (with one side a bit longer than the other) for instance can have configuration ‘3,2,1’ or ‘2,2,2’. Note that ‘2,2,2’ is a configuration of a 2-by-3 square (and all others are a derivative of it).

In fact, every shape that has ‘3,2,1’ as a configuration also has ‘2,2,1’ as a configuration. However, I can’t find a more general derivative rule in order to make ‘2,2,2’ a derivative of ‘3,2,1’ (and also ‘2,2,2’ of ‘3,3’ and ‘1,3’ of ‘2,2’). Maybe I will think about that.

Anyway, a program has been made so you can find KenKen combinations. This is actually an easy thing to program on the whole. I’ve also used a slight modification of it to find all unique sums in more types of shapes. (The program works for products and such as well but it is less useful information.)

Download

(The front-end is made in Multimedia Fusion)

And the new cheat sheet is here.