public
Created

  • Download Gist
gistfile1.rkt
Racket
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
(define cutA 7)
(define growA 3)
(define cutB 5)
(define growB 2)
 
(define (attack-monster heads)
(use-sword heads 0 '()))
 
(define (use-sword n grow s)
(cond ((< n 0) 0)
((= n 0)
(print s)
(newline)
1)
(else (+ (use-sword (- (+ n grow) cutA) growA (append s (list "a")))
(use-sword (- (+ n grow) cutB) growB (append s (list "b")))))))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.