A VimGolf in Emacs Challenge

I’ve been obsessing and writing about the continuing NSA scandal and as a result we haven’t had any fun with VimGolf for a while. Just in case you’re as rusty as I am, here’s an easy one.

Starting with

one two
three

transform it to

(one) (two)
(three)

in the minimum number of keystrokes.

It’s easy to do this with a straightforward query-replace-regexp in 14 keystrokes, which is about the average for the VimGolfers. A slightly more clever use of query-replace-regexp gets the job done in 10, which is better than all but one of the VimGolf solutions.

Those are fairly pedestrian solutions but we can do better by leveraging some Emacs power. Using a macro in conjunction with paredit does it in 6. Unfortunately, the best VimGolf solution takes only 5. So it’s up to our Irreal experts to save the honor of Emacsers everywhere. Add your solutions to the comments and I will post mine in a few days.

Update: I forgot the give a link to the original VimGolf problem. Here it is. Also, I notice that the solution that solved it in 5 (7 according to VimGolf rules) has been removed. I don’t know what that means.

Vimgolf → VimGolf

This entry was posted in General and tagged . Bookmark the permalink.