Sunday, July 26, 2009

Here's an idea

Abdul Kalam's supposed humiliation at the hands of the Continental Airlines security staff has kicked off a much needed debate on the privileges our so called VIPs enjoy. Here's an idea: instead of referring to these folks as VIPs, why not start calling them SLs (short for Security Liability)? This would a) take away the sheen associated with the original tag and b) lower the cost to the exchequer (the assumption being that the politicos would be shamed into requesting that they do not want to be provided security, owing to the negative connotation of the new tag).

Wednesday, July 08, 2009

The Rajapaksa interview

The Hindu is carrying an interview with the Sri Lankan president. Most of his answers are politically correct and are what we want to hear -- man, he's one smooth operator, alright -- but this one exposes his true colours:
Q: There has been international concern over the assaults and pressures on journalists in Sri Lanka. Some of these journalists were your personal friends, especially Lasantha Wickrematunge [Editor of The Sunday Leader] who was gunned down in January 2009. Then, in June, a Tamil woman journalist [Krishni Ifhan née Kandasamy of Internews] was abducted in Colombo by unidentified persons [who questioned her for several hours before releasing her in Kandy].

A: Most of these cases were created, I would say. If you fight someone in the street and that man comes and hits you, can the government take responsibility? But we have not done anything against journalists even when they attack us.
Nice dodge.

BTW, in case you haven't done so already, go and read 'And then they came for me', Lasantha Wickrematunge's voice from beyond the grave -- without doubt the most poignant thing I've read in a long while.

Monday, July 06, 2009

Eight queens problem in Lisp

(defun solve-n-queens (n)
  (let ((solutions nil))
    (defun solve-internal (board k)
      (if (eq k (- n 1))
        (dolist (x1 (solve board k))
          (push x1 solutions))
        (dolist (x2 (solve board k))
          (solve-internal x2 (+ k 1)))))
    (solve-internal (make-board n) 0)

(defun solve (board k)
  (let ((solutions nil))
    (dotimes (i (length board))
      (if (present? i k (get-safe-squares board))
          (push (place-queen (clone-board board) (list i k)) solutions)))

Helper procedures left as an exercise for the gentle reader.