 (defun vimgolf-count-keystrokes ()
   (apply '+ (mapcar 'length (mapcar 'car vimgolf-keystrokes))))
 
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Managing and scoring challenges
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defun vimgolf-solution-correct-p ()
+  "Return t if the work text is identical to the solution, nil otherwise."
+  (let ((case-fold-search nil)
+        (work vimgolf-work-buffer-name)
+        (end vimgolf-end-buffer-name))
+    (flet ((point-min-in (buf) (with-current-buffer buf (point-min)))
+           (point-max-in (buf) (with-current-buffer buf (point-max))))
+      (zerop (compare-buffer-substrings
+              (get-buffer work) (point-min-in work) (point-max-in work)
+              (get-buffer end) (point-min-in end) (point-max-in end))))))
+
+(defun vimgolf-wrong-solution ()
+  (message "Wrong!")
+  (vimgolf-diff))
+
 (defun vimgolf-right-solution ()
   (message "Hurray! You solved %s in %d keystrokes!" vimgolf-challenge (vimgolf-count-keystrokes)))
 

    (vimgolf-mode t)))

(defun vimgolf-kill-existing-session ()
  (dolist (buf (list vimgolf-start-buffer-name
                     vimgolf-work-buffer-name
                     vimgolf-end-buffer-name

(defun vimgolf-quit ()
  "Cancel the competition."
  (interactive)
  (vimgolf-enable-capture nil)
  (vimgolf-kill-existing-session)
  (set-window-configuration vimgolf-prior-window-configuration)
  (message "I declare you, n00b!"))

