Skip to content

Instantly share code, notes, and snippets.

@dongweiming
Last active December 20, 2015 04:09
Show Gist options
  • Save dongweiming/6068549 to your computer and use it in GitHub Desktop.
Save dongweiming/6068549 to your computer and use it in GitHub Desktop.
(defun score (dice)
(reduce #'+ (mapcar #'(lambda (n)
(let ((coun (count n dice)))
(case n
(1 (cond ((= coun 3) 1000)
((< coun 3) (* 100 coun))
((> coun 3) (+ 1000 (* 100 (- coun 3))))))
(5 (cond ((= coun 3) 500)
((< coun 3) (* coun 50))
((> coun 3) (+ 500 (* (- coun 3) 50)))))
(otherwise
(if (>= coun 3)
(* n 100)
0)))))
(remove-duplicates dice))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment