adventofcode

https://adventofcode.com/
Log | Files | Refs

commit fc6bea7bbf24f1d0a79720a13dfa2871b15c2525
parent 17fe83324fb7be8b4c3df67c3ed4e47e3bedb58b
Author: mpizzzle <m@michaelpercival.xyz>
Date:   Thu,  3 Dec 2020 12:19:07 +0000

minor refactoring

Diffstat:
M2020/puzzle_3.scm | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/2020/puzzle_3.scm b/2020/puzzle_3.scm @@ -3,9 +3,10 @@ (define (count-trees tree-map x y x-offset y-offset) (if (not (null? tree-map)) - (+ (if (= (modulo y y-offset) 0) - (+ (check-slice (car tree-map) x)) 0) - (count-trees (cdr tree-map) (if (= (modulo y y-offset) 0) (+ x x-offset) x) (+ y 1) x-offset y-offset)) + (let ((parity (= (modulo y y-offset) 0))) + (+ (if parity + (+ (check-slice (car tree-map) x)) 0) + (count-trees (cdr tree-map) (+ x (if parity x-offset 0)) (+ y 1) x-offset y-offset))) 0)) (load "read_lines.scm")