Download Subset Sum Problem Solver

Download the free Subset Sum Problem Solver  here.

Sometimes it’s useful to be able to decide which numbers from a list add to a target number.

Accountants quite often need to do this – imagine a cheque coming in for say $167.26 without any explanation, and having to try to match it to a list of invoices so that you can mark off which ones have been paid. Or picking up a bank reconciliation, and finding that the cash book balance has changed because new journals have been posted, and then having to work out which entries those are (they sum to the difference in the balance.)

There’s someone who wanted to do something like that here.

The problem, surprisingly enough, has been studied in Computer Science and is called the “Subset sum problem”. It is, in fact, an NP-complete problem, meaning that if you have a big enough list, all the solutions may never be found.

There is a program (in C# .Net) to help solve simple subset sum problems here.

It’s very straightforward to use – double click to open it. Then, separately, open an Excel spreadsheet. Enter the list of numbers on the cells of the spreadsheet (anywhere will do; decimals will work) on Sheet1. Then drag and drop the spreadsheet onto the application. Enter the target in the textbox and press the “Go” Button. The solution(s) will be shown in an Excel workbook.

Connecting a Wii Classic Controller to a laptop PC

The Wii Controller is bluetooth enabled so as long as you have bluetooth capabilities on your laptop or PC, you should be able to connect it.

1. Open Control Panel on the PC. Then click on the “Devices and Printers” icon.

2. Click “Add New Device.”

3. Press the 1 and 2 buttons (both together at the same time) on the Wii controller until the device is seen by Windows.

4. When it is finally seen, Windows will then ask if you want to pair the device with code. Click “No Passkey.”

5. The device drivers will load and the Wii will supposedly be ready. HOWEVER, for some reason, on my laptop, within a minute it has disconnected again. I have to go back through steps 1 to 4 again. The second time it stays connected.

6. Install Carl Kenner’s Glove Pie . Unzip Glove Pie to a new folder. I downloaded GlovePIE 0.45 Free (with Kinect support) which didn’t seem to work for me, and GlovePIE 0.40 which did.

There are 2 exe files and the one that works for me is GlovePIE_bird_5DT.exe.

7. Run Glove Pie.

8. There are 3 tabs at the top of the Glove Pie interface marked “Untitled”, “Gui” and “Variables”. Click on the GUI tab. This is where you can “teach” Glove Pie what PC output matches is supposed to match what controller input. Click “Detect Output to Emulate” and then keeping click the left mouse button (or its laptop equivalent.)  Eventually Glove Pie acknowledges you’ve been clicking the left mouse button by showing Output Device as “Mouse” and highlights “LeftButton.” Then the idea is you go to “Detect Input” and keep hitting whichever button on the controller you want to act as the left mouse button. Glove Pie then writes a script which you can see in the “Untitled” tab. Tell it to run and everything should work as you directed.

But….

It is actually much easier to use the ready made templates. These are bundled in a separate folder with the GlovePie 0.45 Free download with the extension PIE (but I couldn’t find them in 0.40.)

9. In Glove Pie, pick open, find the .PIE file you need in the folder you downloaded, unzip and load. The one’s marked Classic are for the Wii Classic Controller.

10. Tell Glove Pie to Run the scripts

11. Then, as a precaution, open up Microsoft Word or Notepad and check that when you move the Wii Classic Controller’s toggle a whole load of AAAAA’S and WWWWW’s etc are written onto the opened document. If that’s not happening, something is not working. Check the Wii Controller is still showing as a Bluetooth device. If not reconnect. If it is and still nothing is happening in Word, remove Device and start over again. It sometimes seems to help to use the GUI tab in Glove Pie and to tell it explicitly the input device is keyboard and the output device is Classic.

12. When you have it all working, play your game.

Best free games to play with the controller  –

Minecraft for free

Indiana Jones Lego Demo

Transformers Demo

In fact the whole process, on my Samsung laptop, appears to be incredibly flaky. But when you get it to work it is a lot of fun.

Adding a Background Image to a Views Table in Drupal

1. Add this to your sub-theme’s CSS file to get a background image behind the whole table, replacing NAMEOFVIEW with the name of your view and NAMEOFIMAGE with the name of your image:

(if you don’t know how to set up a sub-theme and edit its CSS file then read this and this.)

.view-NAMEOFVIEW table {background: transparent url(/sites/default/files/NAMEOFIMAGE.jpg); background-repeat: repeat; }

.view-NAMEOFVIEW td {background-color: transparent;}

.view-NAMEOFVIEW tr.odd {background-color: transparent;}
.view-NAMEOFVIEW tr.even {background-color: transparent;}

You can see what it looks like here.

2. To specify a background image on particular row of view table:

.view-NAMEOFVIEW tr:first-child+tr +tr+tr+tr+tr+tr, /*7th row because its first plus 6 tr’s */
.view-NAMEOFVIEW tr.info {
background: transparent url(/sites/default/files/NAMEOFIMAGE.jpg);background-repeat: no-repeat;background-position: relative;display:inline-block;width:650px}

or you could use 

.view-NAMEOFVIEW tr:nth-child(7),
.view-NAMEOFVIEW tr.info {
background: transparent url(/sites/default/files/NAMEOFIMAGE.jpg);background-repeat: no-repeat;background-position: left;}

which only works IE7 and later.

How to remember what Gauge Theory’s about without really trying

In physics, gauge theories are theories of fields. The fields can’t be seen, but they give rise to observables. It’s the observables we measure directly. The fields can be configured in different ways and all these different ways are connected by symmetries. These different configurations give the same observables.

The fact that the observables don’t change is called gauge invariance.

Imagine Mario on a planet. The planet has round stones on the surface and each stone has a pink line pointing in a certain direction. The pink line is a measurement of some potential.

Luigi is on a similar planet, same size, same stones, same everything. Mario wants to tell Luigi what direction the pink lines are pointing on his planet.

So he fixes a flag on the ground. (He’s agreed with Luigi where the flag should be located). 

Then Mario draws yellow lines from the centre of the stones in direction of the flag.

What he has done by planting the flag in the ground is fix a gauge.

Now Mario can read off the angle between the yellow and the pink lines and send the information to Luigi. (They will also need to agree which way round they are measuring things – clockwise or anticlockwise).

Now what if Mario moves the flag?

The pink lines are still in exactly the same position. They haven’t changed and the wind hasn’t changed. 

But the flag is in a different position. The gauge has been changed. So Mario has to draw new yellow lines. Then he measures new angles.

The wind is an observable. The flag fixes the gauge. The observables are invariant under the gauge transformation. This invariance under the transformation is called a symmetry. The gauge transformation in this case is not global – Mario can’t simply add the same amount to each angle when he moves the flag to get the new co-ordinate reading. The transformation is local – it varies place to place, but that doesn’t mean it’s arbitrary.

We can add a few more terrifying terms from physics – the planet is the base space. The stones are a circle bundle. The fibre of the circle bundle are all the possible directions the yellow lines could point in. The yellow lines they actually point in are a section of the circle bundle.

The base space doesn’t have to be a planet. It could be anything. It could be a line. And instead of circular stones on the surface of the planet, we could have lines rising upwards. Then we would have a comb.

Or something like it.

A section of the comb might look like this.

Which should remind you of a graph of a function because that what it is.

So a gauge theory is a field theory and theory will involve group actions on fibre bundles.

The simplest example of a gauge theory in physics is electromagnetism.

The electromagnetic field is the field for the electron. We can’t measure the electromagnetic field directly.

If we split the field into its electric and magnetic parts, the electromagnetic potentials V and A are not observable.

The electric field, E, and magnetic field ,B, are observable. We can measure the electric field by setting up a charged ball and an oppositely charged plate and measuring how fast the ball accelerate towards the plate. We can see the magnetic field when we drop iron filings near a magnet and they form themselves into patterns. Electric fields move charges. magnetic fields deflect moving charges. Place a magnet next to a cathode ray TV screen to see this. It’s natural to think of these fields as vector fields.

And then it is equally natural to think these direction and length of all these vectors are the acceleration at which a small mass would fall down a well. The wells are the potentials.

Only the difference in potential is physically measurable.

To model electromagnetism, we set up a complex line bundle on spacetime. Every point in spacetime has a line of complex numbers growing out of it. They are different lengths, like our damaged our comb. We set a gauge and use this gauge to measure off the potential V.