fork download
  1. ; potholes
  2.  
  3. (define (potholes str)
  4. (let ((len (string-length str)))
  5. (let loop ((i 0) (fixes 0))
  6. (cond ((<= len i) fixes)
  7. ((char=? (string-ref str i) #\X)
  8. (loop (+ i 3) (+ fixes 1)))
  9. (else (loop (+ i 1) fixes))))))
  10.  
  11. (display (potholes ".X.")) (newline)
  12. (display (potholes ".X...X")) (newline)
  13. (display (potholes "XXX.XXXX")) (newline)
  14. (display (potholes ".X.XX.XX.X")) (newline)
Success #stdin #stdout 0.01s 7968KB
stdin
Standard input is empty
stdout
1
2
3
3