day 14, part 2 - endless pyramid
This commit is contained in:
@@ -350,3 +350,36 @@
|
||||
(drop-result (drop-sand-unit arena) (drop-sand-unit arena)))
|
||||
((not drop-result)
|
||||
sand-units)))
|
||||
|
||||
;;; PART 2
|
||||
;; let's not do floor infinite.
|
||||
;; let's just give it enough left-to-right?
|
||||
;; since the triangle is 2 right angle triangles, then bottom is 2x height
|
||||
;; so, let's add 4x height of the floor?
|
||||
;;
|
||||
;; new bottommost =
|
||||
(+ 2 bottommost)
|
||||
;; new leftmost =
|
||||
(min leftmost
|
||||
(- 500 (* 2 bottommost)))
|
||||
;; new rightmost =
|
||||
(max rightmost
|
||||
(+ 500 (* 2 bottommost)))
|
||||
|
||||
;; and add new rock-line?
|
||||
;; just through function that adds a rockline
|
||||
|
||||
(slot-value *test-arena* 'grid)
|
||||
|
||||
;; and now i'd like a more compact printing.
|
||||
;; how'd i do that?
|
||||
;; surely there's a way to get access ot a slice of the 2d array?
|
||||
|
||||
(let* ((arena *test-arena*)
|
||||
(array (slot-value arena 'grid)))
|
||||
(dotimes (row (array-dimension array 0))
|
||||
(dotimes (col (array-dimension array 1))
|
||||
(format t "~a" (aref array row col)))
|
||||
(terpri)))
|
||||
|
||||
(drop-sand-unit *test-arena*)
|
||||
|
||||
Reference in New Issue
Block a user