Gigabytes, terabytes and beyond….to Geopbytes

Megabytes, Gigabytes, Terabytes – What Are They?

· 1 Bit = Binary Digit
· 8 Bits = 1 Byte
· 1024 Bytes = 1 Kilobyte
· 1024 Kilobytes = 1 Megabyte
· 1024 Megabytes = 1 Gigabyte
· 1024 Gigabytes = 1 Terabyte
· 1024 Terabytes = 1 Petabyte
· 1024 Petabytes = 1 Exabyte –
· 1024 Exabytes = 1 Zettabyte
· 1024 Zettabytes = 1 Yottabyte
· 1024 Yottabytes = 1 Brontobyte
· 1024 Brontobytes = 1 Geopbyte

Talk about lots of cool Scrabble words. They also have a “Byte Converter”:http://www.whatsabyte.com/P1/byteconverter.htm that tells you for instance 100MB is 104,857,600 bytes 🙂

Rewriting the Anagram program

As Calvin pointed out, its a pain to do the string length and other calculations, so I went back and rewrote the anagram calculation using the prime number trick. That is, assign a prime to each letter from ‘a’ to ‘z’, then you can easily tell if two words are anagrams by multiplying all the prime factors. This will give a unique number.

There are two tricks. First, if you assign too big a prime then you can get an overflow. On a Mac running gcc, the largest integers are 64 bits long. C represents these as “unsigned long long int” which is quite a mouthful. Given there are 26 letters in the alphabet, the worst case would be the 26th prime 103 times 10 before you over flow (103^10 > 2^64). This is pretty unlikely in a real world dictionary.

To make it less likely, you can pick an encoding where the most “frequent”:http://scottbryce.com/cryptograms/stats.htm letters have the smallest prime. That is E is the most likely in english, so assign it a prime of 2, T is next, so assign it prime of 3 and so forth (for your reference, the letter order by decreasing frequency is ETAOIN SRHLDC UMFPGW YGVKXJ QZ and using the Encore scrabble dictionary, the word with the highest prime is adrenocorticotrophin with a canonical number of 18,438,608,663,595,509,046 or 1.8 x 10^19 which is just shy of 2^64 which is 1.8×10^19, but you should have a check for integer overflow.

The code is really simple then, you just multiple the encoding prime for each letter and then match it against the canonical “number” for each entry in the dictionary.

Anagram Games

Found lots of anagram exercises on the web from Stanford and Duke in particular, but found one that is a simple game that is pretty easy to understand:

* “Devdaily”:http://www.devdaily.com/java/jwarehouse/netbeans-src/usersguide/j2seexamples/anagrams/src/com/toy/. This one is a little complicated, but basically it shows you a scrambled word and you have to figure out how to unscramble and turn it into a real word.

There are also lots of completed programs on the web and even whole sites devoted to it. That’s because anagrams are essentially what Scrabble players need. Take a jumble of letters and turn them into potential words and you can just google:”Anagram” to see literally dozens of games.

* “Wordsmith.org”:http://wordsmith.org/anagram/advanced.html. There is a whole site devoted to anagrams and a more advanced program that takes an entire phrase and converts it.
* “Andy’s Anagram Solver”:http://www.ssynth.co.uk/~gay/anagram.html Has a really big 132,000 word dictionary. See how many ways there are to scramble Lakeside! into French.
* “Brendan’s Anagram Generator”:http://www.mbhs.edu/~bconnell/cgi-bin/anagram.cgi. This one tries to take a word and turn it into English. It uses Evan’s program.