Xah Lee has contributed a challenge that serves as an excellent example of one of the types of problems I think we should concentrate on if we start an EmacsGolf site. I like this problem because it is a real problem of the type that Emacs users encounter every day.
Lee has a minor mode, xmsi-mode, that is useful for mathematical input (it’s very handy if you do that sort of thing; check it out). Recently, he was refactoring the code and wanted to change lines like
(puthash "■" "□" xmsi-abrvs) (puthash "□" "■" xmsi-abrvs) (puthash "●" "○" xmsi-abrvs) (puthash "○" "●" xmsi-abrvs) (puthash "◆" "◇" xmsi-abrvs) (puthash "◇" "◆" xmsi-abrvs) (puthash "▲" "△" xmsi-abrvs) (puthash "△" "▲" xmsi-abrvs) (puthash "◀" "◁" xmsi-abrvs) (puthash "◁" "◀" xmsi-abrvs) (puthash "▶" "▷" xmsi-abrvs) (puthash "▷" "▶" xmsi-abrvs) (puthash "▼" "▽" xmsi-abrvs) (puthash "▽" "▼" xmsi-abrvs) (puthash "★" "☆" xmsi-abrvs) (puthash "☆" "★" xmsi-abrvs) (puthash "♠" "♤" xmsi-abrvs) (puthash "♤" "♠" xmsi-abrvs) (puthash "♣" "♧" xmsi-abrvs) (puthash "♧" "♣" xmsi-abrvs) (puthash "♥" "♡" xmsi-abrvs) (puthash "♡" "♥" xmsi-abrvs) (puthash "♦" "♢" xmsi-abrvs) (puthash "♢" "♦" xmsi-abrvs)
into lines like this
(xmsi-add-cycle ["■" "□"]) (xmsi-add-cycle ["●" "○"]) (xmsi-add-cycle ["◆" "◇"]) (xmsi-add-cycle ["▲" "△"]) (xmsi-add-cycle ["◀" "◁"]) (xmsi-add-cycle ["▶" "▷"]) (xmsi-add-cycle ["▼" "▽"]) (xmsi-add-cycle ["★" "☆"]) (xmsi-add-cycle ["♠" "♤"]) (xmsi-add-cycle ["♣" "♧"]) (xmsi-add-cycle ["♥" "♡"]) (xmsi-add-cycle ["♦" "♢"])
This isn’t a hard problem but how efficiently (in terms of keystrokes) can you solve it? You can use anything in core Emacs, ELPA, or any external tool accessed in the usual way from Emacs. As a baseline, I did it in 29 keystrokes without trying too hard. I’m sure many of you can do better. I’ll be trying too.
Thanks to Xah Lee for generously donating this challenge rather than posting it himself.