Monday, November 12, 2012

Dirty Letterpress

My friend Andy introduced me to an iphone game called letterpress. The concept is pretty simple and the game is easy to learn - you have a board full of letters and you can create words out of any number of them. You get points for ever letter used, subject to some nuances about how they are defended and such.
iPhone Screenshot 1
(The picture is from the appstore link above)

Andy beat me a couple of times quite handily. Which got me thinking about how this was a rather simple string search problem that I was failing at. Enter python.

#!/usr/bin/python
import sys

board = sorted(sys.argv[1].lower())

d = open('/usr/share/dict/words')
for w in d:
s = sorted(w.strip().lower())
if len(s) < 9: continue
i = 0; j = 0
while i < len(s) and j < len(board):
if s[i] == board[j]:
i = i+1
j = j+1
elif s[i] > board[j]:
j = j+1
else:
j = len(board)
if i == len(s):
print len(s), " ", w.strip()


And the expected results:

letterpress > ./letterpress.py evkrvtzahfcyxvgatiwigoezy | sort -nr
12   vociferative
12   overactivity
12   excogitative
11   viaggiatory
11   theatricize
11   rhyotaxitic
11   overagitate
11   heterotaxic
11   heterotaxia
11   gravitative
11   fevertwitch
11   exhortative
10   whitterick
10   vociferize
10   vociferate
10   victoriate
10   verificate
10   twitchfire
10   thieftaker

Needless to say Andy caught on quite quick that something was amiss :) I resigned.





Wednesday, October 31, 2012

[books] Hydrogen Sonata

The Hydrogen Sonata (Culture, #10)The Hydrogen Sonata by Iain M. Banks
My rating: 4 of 5 stars

Ian M. Bank's latest work is another Culture novel, with all the elements that make culture novels fun - androids, avatars, knife missles, Minds, GSVs. Includes the introduction of another pan-galactic species or two and contrasts between AI-life and bio-life. Its a fun read overall, though not the best Culture novel ever. If you're a Banks fan or a Culture fan, you should definitely read it. If you've never read Ian M Banks before, I would suggest Player of Games or Surface Detail before this one.

View all my reviews

Tuesday, August 21, 2012

[books] Blood Song


Blood Song (Raven's Shadow, #1)Blood Song by Anthony  Ryan
My rating: 5 of 5 stars

Every now and then, you stumble across an author through blind luck (or Amazon's recommendation algorithms) and discover a real gem. This book is one of those.

Blood Song is a great mix of politics, action, mystery, magic - all the elements of an epic fantasy novel. It tracks the life of a warrior from childhood through training into battle. Its ending is semi-conclusive, certainly paving the road for book 2, which I look forward to. Ryan's writing is really great, considering that the book is self published via amazon. Apparently it had a bunch of grammatical and other errors, but they have since been fixed.

At a $2.99 price point, I cannot recommend this book enough. I enjoyed it far more than Wizard's First Rule or A Game of Thrones - the story is very compelling and it has fewer downright nasty or gory bits. The only downside of the book is the lack of history about the world that he builds - the politicking is explained somewhat but nowhere close to the detail that Martin or Tolkien would go into.


View all my reviews

Sunday, July 15, 2012

[books] The Blacksmith's Son


The Blacksmith's Son (Mageborn #1)The Blacksmith's Son by Michael G. Manning
My rating: 4 of 5 stars

The Blacksmith's Son is Michael Manning's first book and it as a really great read. It has some of the traditional elements of fantasy (wizards, mages, runes, spells, hero who doesn't know his power, love interest etc), but the Manning manages to make the story interesting and does a great job with the writing.

The general idea probably feels familiar to anyone who has read sufficient number of fantasy books - hero whose parents were killed when he was a baby, raised in relative poverty, discovers his powers post puberty, love interest, chief antagonist etc. What makes the story and the book interesting is the relatively fresh writing style - Manning inserts enough quirky humor in there and makes the characters seem more 'normal' and less dour than say Tolkien's. Don't expect the deep lore of Tolkien, but its far, far better than say Wizard's First Rule which I hated.

Fun, quick read, I look forward to the next one in the series.


View all my reviews

Thursday, June 21, 2012

Mapping Caps Lock to Control on Windows 7

I find the Caps Lock key completely useless. On all my computers, I map it to the control key. This is rather straightforward to do on a Mac and in Linux, but slightly harder on a Windows 7 machine. Just slightly.

There are a few different tricks that exist on the web, but the easiest I found was the registry hack - all you need to do is create a new REG_BINARY key in HKLM/System/Control/Keyboard Layout (note the singular) called Scancode Map , put in the value below, and restart your machine.

Here is the MSDN article on the Scan Code Mapper. Basically, you can instruct it to remap keys to do whatever you wish. Two common configurations:


1. Map Caps Lock to Control (this is what I use) -  
00000000 00000000 02000000 1D003A00 00000000


2. Swap Caps and Control (I have no idea why someone would want to do this)
00000000 00000000 03000000 3A001D00 1D003A00 00000000

Obviously, use this at your own risk (though I think the risk of something going dramatically wrong is very minor). For the nerds, read the aforelinked MSDN article - the numbers actually make sense.

Saturday, May 12, 2012

[books] Reamde

ReamdeReamde by Neal Stephenson
My rating: 3 of 5 stars

Better than Anathem worse than Snow Crash. Fast read and a lot of fun. Much more like Snow Crash than any other recent Stephenson book - almost like his comeback novel. This is a fast paced adventure through a bunch of countries - mixing in computers, security, terrorisms, guns and what have you. I have always loved Stephenson's detail - his computer environments, his knowledge of how computer security actually works - all quite legitimate. This adds a sense of believability to his books that I really enjoy. If you like vintage Stephenson (ie not the Baroque Cycle stuff), you'll like this.

View all my reviews

[books] Ready Player One

Ready Player OneReady Player One by Ernest Cline
My rating: 4 of 5 stars

Fast, fun, awesome read. If you like Neal Stephenson, you'll like Cline. Immaculately researched, really readable, great combination of real and virtual worlds. Somewhat predictable, language is rather straightforward (unlike, say, Feersum Endjinn), but overall a wholly enjoyable read. Recommended.

View all my reviews

Sunday, June 12, 2011

Faster DNS Servers - namebench

Choosing the right DNS servers can make all the difference between a fast and snappy web browsing experience and a slow and untolerable one. I came across a utility called namebench, published by Google to test out DNS server speeds. It takes about 5 minutes and could result in a faster web experience - I would recommend giving it a shot. In my case, comcast is the fastest DNS server, so no changes needed to be made, but your environment may be different.





Full Disclosure: I work for Google. I do not work on Namebench. Please use it at your own risk.

Sunday, April 10, 2011

[books] Surface Detail


Surface DetailSurface Detail by Iain M. Banks
My rating: 5 of 5 stars

Ian M. Banks's latest Culture novel is, in my opinion, his best work to date. For the uninitiated, Culture novels usually revolve around the Culture, a perfect civilization of sorts, where people live as long as they want, benevolent (and sometimes malevolent) AIs control and provide for everything etc. Except there are tons of races in the galaxy (it is huge, after all) and the Culture deals with those both above and below it on the technological ladder. The most interesting sections of the Culture, Contact (the section dealing with other races) and Special Circumstances (the shady part of Contact) are usually at the center of most of I.M.B.'s Culture novels. No description of any of his works would be complete without mentioning the AIs or Minds as they are called. Generally AIs that control gigantic ships, AIs that are far, far outside the reach of any human, these have their own distinct personalities and play just as important a role in any Culture novel as any human character.

Surface Detail has it all - a new race, an interesting backward civilization, wierd connectons between virtual reality and the Real, crazy (literally insane) AIs with their own quirky personalities. The book is a fast read, I had a really hard time putting it down.

Couple of points of warning:
1. The book has foul language. Lots of it. It is not recommended for children; if it were a movie, it would be NC-17.
2. It is not as depressing as most of Banks's other books (Consider Phlebas for example).


View all my reviews

Tuesday, December 28, 2010

[books] Containment

ContainmentContainment by Christian Cantrell
My rating: 4 of 5 stars

Good pulp fiction - fast read, interesting idea, though not exactly the most original, and generally well written. There is a bit of a mystery element to it, so I won't go deep into the story, but suffice to say that the synopsis on the book misdirects: I was initially put off by it and left this book lie for a while on my kindle after I bought it. I would recommend ignoring it and just dive in. You'll know within the first quarter or so if this book is for you.


View all my reviews