updates to elimate unused variables and enhance readme
This commit is contained in:
@@ -21,7 +21,9 @@ Adding South rows ought to be simple, as that's just pushing all the values furt
|
||||
https://newton.ex.ac.uk/teaching/resources/jmr/appendix-growable.html
|
||||
Upon adding this, I figured that it would be best to adopt a struct to copy the array between instances of it
|
||||
|
||||
Had a chat with am AI, it reckoned that the thing to do was to expand the array by a row or column when Santa was detected as being out of bounds
|
||||
So, it seems that really what I'll be doing is managing arrays of pointers for rows, which is good, as it means that I can let the memory management do its thing without me having to track whether or not I've got a continuous region of memory. I'm also having Santa start out at a 1x1 grid. So I'm adding rows when he's detected out of bounds, by tracking the grid size, his location on the grid, his location relative to the origin and having it add rows when he's above or below the current grid (started off in the vertical axis as it seemed easiest). Had some difficulties with the logic of tracking where Santa is on the grid, took a little while to come to the correct calculations there.
|
||||
|
||||
I really like passing the pointer to the struct to the function in C, it makes things quite elegant (and easier for memory management!) as you're updating fields in a struct rather than creating a new copy each time. There's probably performance benefits, but this is so tiny that I'm unlikely to have to think about that. The new_grid pointers being inserted into the ->houses slot is handy. Did I say I really like only having one struct in play?
|
||||
|
||||
https://adventofcode.com/2015/day/3
|
||||
--- Day 3: Perfectly Spherical Houses in a Vacuum ---
|
||||
|
Reference in New Issue
Block a user