Skip to content

Instantly share code, notes, and snippets.

@lowellbander
Created October 23, 2015 04:42
Show Gist options
  • Select an option

  • Save lowellbander/684d3b3e82827c2c6d16 to your computer and use it in GitHub Desktop.

Select an option

Save lowellbander/684d3b3e82827c2c6d16 to your computer and use it in GitHub Desktop.
(defun h204156534 (s)
(cond
((null s) 0)
(t (+ (delta (first s) 0 0) (h204156534 (rest s))))
)
)
; DELTA returns the absolute value of the difference between the number of
; boxes and goals in ROW. BOXCARRY and GOALCARRY are both expected to have value
; 0 when DELTA is called by a function other than itself.
(defun delta (row boxCarry goalCarry)
(cond
((null row) (absolute (- boxCarry goalCarry)))
((isBox (first row)) (delta (rest row) (+ 1 boxCarry) goalCarry))
((isStar (first row)) (delta (rest row) boxCarry (+ 1 goalCarry)))
(t (delta (rest row) boxCarry goalCarry))
)
)
; ABSOLUTE returns the absolute value of VALUE.
(defun absolute (number)
(cond
((< number 0) (- number))
(t number)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment