- They were finished off in an encounter to do away with the inconvenience of a trial (Update: Turns out they had already finished serving their sentences. Why couldn't they then be simply deported to Pakistan?).
- They escaped from some other place, and the guilty parties are trying to shift the blame.
- Secret deal with Pakistan to release these persons in exchange for undisclosed favours (alright, this sounds too far-fetched)
Monday, January 04, 2010
Speaking of three idiots
I think the universe just winked at me
Wednesday, December 16, 2009
Pay attention to the other hand
- Food prices are up by about 20%
- Uncomfortable questions are being raised about how the intelligence agencies have dropped the ball on the David Headley affair
- The 123 nuclear deal is close to fruition, with the government, going by past form, likely to give the American negotiators what they want.
Tuesday, December 08, 2009
Are you kidding me?
You really have to be illiterate, retarded, or paid off by Exxon to see even the slightest evidence in any of the emails of the slightest wrongdoing.I'm not illiterate or retarded, and last time I checked, there sure weren't any credits to my bank account from Exxon. Yet, considering just one fact -- the attempted circumventing of the FOI regulations by the scientists, yes, you bet your ass I see evidence of wrongdoing. Why is so much hatred and venom being heaped on anyone who is skeptical about man-made climate change?
Sunday, November 22, 2009
The CRU Data Leak
Update: Call me paranoid, but it looks like the Star Tribune story on this has been taken down. Google cache to the rescue. The doofuses forgot to take down the comments page for the story, however.
Monday, November 09, 2009
When play becomes work
-- Jerome K Jeorome
We've all heard of situations (and have probably even experienced them ourselves) where someone liked their work so much that it was almost like play. Well, the reverse happened to me recently: I was working on my entry for the Intel Threading Challenge, and I was nearing the contest deadline, with my entry still missing the key bits of the algorithm. I was almost at the point where I thought I'd put in as much time as it took -- even if it meant staying up half the night -- and finish the damn thing, when it suddenly hit me: I'm supposed to be enjoying this; I'm working on this in my spare time, after all. I switched off the computer, and next morning, well past the deadline, when I thought I'd experience a pang of guilt at missing the submission, all I experienced was the thought of hacking together the code at my own pace, enjoying myself, and well, having fun.
Thursday, November 05, 2009
Rukhsana appointed special police officer
Thursday, October 22, 2009
Jail term for thowing footwear
Thursday, October 08, 2009
Here's a thought experiment
Do you think any of the Third World debtors would have gotten away with it if they had tried to pull the same stunt as Iceland? Any talk about how their "position as a sovereign state precludes legal process against their assets which are necessary for them to discharge in an acceptable manner their functions as a sovereign state" would only have elicited a "Nice try, just STFU and cough up the money". However, I'm sure the fact that they are not denizens of the civilized white western world would not have had anything to do with such a response. Not.Icelanders for their part feel that the EU has treated them as a financial colony while backing a neoliberal kleptocracy preying on an increasingly indebted population. In many ways Iceland is the tip of the iceberg – the proverbial canary in the coal mine showing the need to better cope with over-indebted economies. The EU and IMF-style austerity programs to pay off foreign debts that corrupt insiders have run up is not what was promised in 1991 (to) the post-Soviet economies or Third World debtors. It is not the promise of industrial capitalism. It is a financialized post-industrial dystopia, an imperial neofeudalism.
...
Instead of imposing the kind of austerity programs that devastated Third World countries from the 1970s to the 1990s and led them to avoid the IMF like a plague, the Althing is changing the rules of the financial system. It is subordinating Iceland’s reimbursement of Britain and Holland to the ability of Iceland’s economy to pay
Wednesday, September 30, 2009
For a second there I thought you said '14 lakhs'
Mohandas Karamchand Gandhi’s iconic Dandi March in 1930 to protest against the British salt tax has inspired pen-makers Mont Blanc to come out with a limited-series pen on the Father of the Nation.You can't make stuff up like this even if you tried: using somebody whose life was the epitome of simplicity to sell a fricking designer pen that costs Rs. 14 lakh.
The high-end pen is priced around Rs.14 lakh, according to a watch retailer.
The pen comes with a gold wire entwined by hand around the middle, which "evokes the roughly wound yarn on the spindle with which Gandhi spun everyday."
There's a bright side to this, though: all we have to do is hook up some magnets and coils of copper wire to Gandhi's mortal remains in Raj Ghat, and voila, an instant solution to our perennial power shortages.
Thursday, September 24, 2009
Somebody please take the keyboard away from him
By the way, studies have shown that cutting down your twittering by even as little as five tweets a day can allow one to fit in an average of 1.2 extra engagements in an already 'ridiculously full' day.
Wednesday, September 23, 2009
Question
Indiaplaza even went so far as to send an email masquerading as a review of the book, with the reviewer practically wetting themselves in their praise. Wait, I think I was too harsh -- reading the review more closely, it looks like a really different plot this time: last time it was a French scholar who requests a meeting with Langdon and dies before the meeting could take place, leaving behind a tantalizing clue, while this time it's an American professor who pulls more or less the same shit. My bad.
Update:The Onion chips in:
Most chillingly, many agreed, is that while Michael Crichton's death has been a positive step, Dan Brown remains very much alive.
World Bank approves $4.3 billions in loan to India
Monday, September 21, 2009
The hydrogen bomb controversy
The thermonuclear device had a yield of 45 kilotons. I have chosen my words carefully — 45 kilotons and nobody, including Mr. Santhanam who has absolutely no idea what he is talking about, can contest what is proven fact by the data which is thereI find it hard to believe that the DRDO project lead in charge of the whole thing (i.e. Santhanam) doesn't have a clue what he's talking about.
Asked about the doubt the former Army Chief, V.P. Malik, had raised about the efficacy of the hydrogen bomb, he said: “I think the person to answer that, is the present chief and not the past chief…”Just because someone has retired from his post, he doesn't lose whatever credentials he may have built up over his career. Reading along:
“We have thermonuclear capabilities. I am absolutely sure. We are very clear on this point. If you hit a city with one of these you are talking about 50,000 to 1,00,000 deaths,” the NSA said.Just saying so repeatedly will not cut it. Also, does anybody else find such casual mention of deaths more horrifying than Santhanam's statements?
One can understand where Narayanan is coming from: after all, proclaiming to the whole world that our hydrogen bombs are duds is not exactly good for the morale of the country and would cause our enemies quite a lot of satisfaction, but going after those who are interested in the truth doesn't serve any purpose, either.
Saturday, September 19, 2009
Haskell, monads, graph theory and the puzzle that took 19 years to solve
Given the figure below, find a path from point A to point B that crosses every edge line segment exactly once:

I came upon this when I was in college, and spent an hour or so on it, trying out different paths by hand, but could not find a solution.
Nineteen years later, The Communications of the ACM carries an article on the P=NP question, which triggers an impulse in me to read up more on the complexity of algorithms, and I learn about graph theory, DFS, BFS, the entire works. Quite a fascinating subject. Anyway, the upshot of all this is that I realize that there is a formal method of solving the puzzle that had piqued my curiosity nearly two decades ago.
Coincidentally, my copy of Real World Haskell arrives at my doorstep at around the same time I am thinking of whipping up some code to solve the puzzle. Learn Haskell, solve puzzle. One stone, two birds.
The first thing is to come up with the data structures. Not too difficult (apologies for the screwed up formatting -- getting all the tabs correct in Blogger would probably take me four hours):
type Node = Int
type Edge = (Node, Node)
type Path = [Node]
type Graph = ([Node],[Edge])
theGraph :: Graph
theGraph = ([1,2,3,4,5,6], [(1,2),(1,3),(1,4),(1,2),
(2,3),(3,4),(1,4),(2,5),
(3,5),(3,6),(4,6),(1,5),
(5,6),(1,6),(1,5),(1,6)])
One of the options I considered initially was to model the direction of the path, something along the lines of
type Path = [(Edge,Direction)]
with Direction indicating whether we are going forward or backward, but it turns out that this was not required.
Having gotten the data structures in place, it's just a question of routine code to put together the helper functions that will be needed:
-- to check whether two edges are the same [(1,2) is equal to (2,1)]
edgeEq :: Edge -> Edge -> Bool
edgeEq e1 e2 = e11 == e21 && e12 == e22 ||
e11 == e22 && e12 == e21
where e11 = fst e1
e12 = snd e1
e21 = fst e2
e22 = snd e2
-- get all the edges joined at a node
getEdges :: Node -> [Edge]
getEdges node = [edge | edge <- snd theGraph, fst edge == node || snd edge == node]
-- get the node at the other end of an edge
getOtherEnd :: Node -> Edge ->Node
getOtherEnd node edge = if fst edge == node then snd edge else fst edge
-- get all the neighbours for a node
getNeighbours :: Node -> [Node]
getNeighbours node = map (getOtherEnd node) (getEdges node)
-- converts a path into a list of edges (e.g. [1,2,3,2] to [(1,2),(2,3),(3,2)]
buildEdges :: Path -> [Edge]
buildEdges path | null path || length path == 1 = []
| otherwise = (head path, head (tail path)) : buildEdges (tail path)
-- get the list of neighbouring nodes that are yet to be visited in the current path
getUnvisitedNeighbours :: Node -> Path -> [Node]
getUnvisitedNeighbours node path = map (getOtherEnd node) untravelledEdges
where untravelledEdges = deleteFirstsBy edgeEq (getEdges node) (buildEdges path)
-- check whether a given path is a solution
isSolution :: Path -> Bool
isSolution path = head path == 5 && last path == 6 && length path == length (snd theGraph) + 1
The astute reader will observe that the graph object -- is it OK to call things 'objects' in Haskell? -- is baked into the solution; I initially had a version where the graph object was passed as a parameter to every function, but this made things more verbose, and anyway, my objective was not to produce a graph library, but to solve the puzzle.
With that out of the way, time to move on to the actual algorithm. The algorithm is a DFS brute search, where we start at a node (note that the area outside the figure is also modelled as a node), choose one of its unvisited neighbours, choose one of the neighbour's unvisited neighbours, and so on, till we run out of neighbours to visit. Check the path to see if we have covered all the edges and if the path is bookended by the start and end nodes that are of interest to us, and we have our solution. An NP-hard problem, BTW.
It's obvious that recursion is needed here, but I was not sure how to handle the enumeration of the different branches, the backtracking from a dead end, and so on in Haskell, considering that looping is frowned upon, and the strongly typed nature of the language implies that both the if and else clauses should return the same type, i.e. you cannot do the equivalent of:
if <path is a solution>
then <print solution>
else <add next neighbour and try again>
While working on the solution, I was also reading up on monads, and man, are they a pain to wrap your head around. But luckily I ran into [*] Monads as containers (and its sibling Monads as computation, which I'm still digesting), where I learned that a list is also a monad, and we can do stuff like take a list, apply a function that produces a list, and end up with a flat list, so to speak (yeah, we don't need monads for this, a simple map and concat are enough, but I learned this in hindsight, after realizing that >>= was exactly what I was looking for). Anyway, that sort of nails the algorithm:
-- build a list of candidate paths for a given path
getNextChoices :: Path -> [Path]
getNextChoices path = nub (unvisitedNodes >>= (\x -> [reverse (x : reverse path)])) -- hack to append to end of a list
where unvisitedNodes = getUnvisitedNeighbours (last path) path
-- filter out all the solutions from a given list of candidate paths
findSolutions :: [Path] -> [Path]
findSolutions paths = filter isSolution (nub paths)
-- find all the solutions starting from a given list of candidate paths.
-- invoked with a single node path, i.e. solve [[1]]
solve :: [Path] -> [Path]
solve paths = if null choices
then findSolutions paths
else solve choices
where choices = (paths >>= getNextChoices)
solve' :: [Path]
solve' = solve [[5]]
From All About Monads:
One use of functions which return lists is to represent ambiguous computations -- that is computations which may have 0, 1, or more allowed outcomes. In a computation composed from ambiguous subcomputations, the ambiguity may compound, or it may eventually resolve into a single allowed outcome or no allowed outcome at all. During this process, the set of possible computational states is represented as a list. The List monad thus embodies a strategy for performing simultaneous computations along all allowed paths of an ambiguous computation.The above algorithm is not exactly an ambiguous computation, but the bit about "performing simultaneous computations along all allowed paths" sure resonates with its structure.
And now for the denouement, which by the way, takes a looong time (remember the NP-hardness):
*Main> solve'
[]
Nope, still no solution.
[*] It doesn't reflect too well on a book if I still have to rely on Google to help me out. I'm looking at you, "Real World Haskell".
Sunday, September 06, 2009
Thank you

Salsa-dancing, shopping-at-Marks-and-Spencers investment bankers -- yeah, this is the most representative Indian demographic.
And using Phil Collins' Another Day in Paradise as the investment banker's favourite song? These guys won't know it if irony jumped up and bit them on their asses.
Thought for the day
-- From Real World Haskell
Saturday, August 29, 2009
Little things
IE: Prompt for saving the password before sending the request, which may result in storing an incorrect password (because of a typo).

