Friday, April 25, 2008

Tiny USB Stick

I recently bought this tiny 2GB USB stick. It's an Advent Slider (I think), and it cost £12 from PC World, which seemed like a reasonable price, even though I was in PC World.

It comes with a little cord to attach to your keyring, and as it only weighs 2-3g (according to my kitchen scales) it's light enough to actually carry around on your keyring without you actually noticing you've got it with you.

As the name Slider suggests the bottom of the device slides out to make a USB connector, slightly narrower than the overall width of a USB port. Which is nice because, as well as being 8 times smaller capacity than this one, my current USB stick blocks the adjacent USB port on my laptop when it is plugged in.

The only niggle is the normal one when you buy mass storage devices. Which is that mass storage manufacturers insist on specifying capacities of their devices as if 1GB was 1,000,000,000 bytes, whereas computers are programmed to think 1GB is 1,073,741,824 bytes (= 1024 × 1024 × 1024). So when you select 2GB of photos and drag them to the stick, they don't actually fit. The actual capacity of this stick is 2,021,654,016 bytes (raw) and 2,021,621,760 (FAT32 formatted as packaged), which is technically 1.88GB.

I have to say that for the layman [1], I think that it does make more sense for 1GB = 1e9 bytes (and likewise, 1MB = 1e6 bytes and even 1KB = 1000 bytes), and it makes it easy to look at the byte count of a chunk of data and translate it easily into the appropriate units by just taking the correct prefix of the base 10 amount. The only drawback is that it flies in the face of many years of computer science teaching.

Of course the situation we are in at the moment, where computers report base 2 units and mass storage manufacturers artificially inflate the capacity of their products by quoting unformatted base 10 units, is the worst of both worlds. But I don't expect it to improve any time soon. Even worse is the idea of introducing a parallel series of units (kibibytes, mebibytes, gibibytes) to compound the confusion.

Anyway, I've been carrying it around on my keyring since I got it. I've not used it for anything interesting yet, but when I need it it will be there.

[1] layman/lame-man is an example of an eggcorn. As in "to put it in lame-man's terms". Read more about eggcorns at The Eggcorn Database.

Thursday, April 24, 2008

Enigma 1491: Tile trials

I've recently found myself with more time on my hands, so I renewed my subscription to New Scientist and have been using the weekly Enigma puzzles to provide me with a weekly pragmatic programming exercise.

Normally these are amenable to short Perl program to analyse the problem space to come up with the solution in a few seconds. However this week's was a bit trickier:
Tile trials

DICK has a box of rectangular tiles. Each is a different size, the dimensions being 1 × 3, 2 × 4, 3 × 5, 4 × 6 and so on.

He takes some tiles out of the box, first the 1 × 3, then the 2 × 4, then the 3 × 5, and so on, with the aim of fitting together all those that he has taken into a rectangle that has no gaps and no overlaps.

Assuming he takes more than one tile out of the box, how many tiles must he take out to create (a) the smallest possible rectangle, and (b) the next smallest possible rectangle?

New Scientist Enigma 1491, Richard England

The Perl program I wrote ran and found the first solution in a few seconds, but took 50m26s to find both the necessary solutions. So while it was running I wrote an equivalent program in C. It's been a few years since I did any serious C coding, but once I remembered what the equivalent C constructs to Perl's next and last were (continue and break), I got it compiled and it ran and found the solutions in 11.3s.

Thursday, April 17, 2008

First Post!

Shortly after I set up my first web site in 1994 I added a section to it called Jim's Web Of Consciousness, which described itself thusly:

"This page is a random collection of things that may or may not prove interesting. It grows from the bottom up."

It perhaps says something about the high regard that I held this page that it resided under a path of /junk on my site.

Of course it was only available to people with access to the HP Intranet (i.e. people that worked at HP), but at the time that included the vast majority of people who knew me who had access to the internet, so it didn't seem like much of a problem.

Fourteen years later I've decided the time has come for me to add a random collection of things that may or may not prove interesting to my current web site, and that's exactly what we call a blog nowadays.

So here it is. At some point I will link it in more closely to my site, but for now I shall just add things to it as I see fit.

If you know me and you've managed to find this blog feel free to leave a comment.