#+title: Notes * ok. let's try this. i'd want to have block type with function to get it's XY coords i'd want to settle blocks first. but if i store enough data, for example block.supports slice i'll be able to anser first task. (settledOnZ) i would want [][]*Block per level from 0 to up. with references to blocks that settled on that level (maxSettledXY) and for going from 0 up i'll want XY of the top block settled with it's level. i guess i could store settled level in the block as well then for settling blocks, i will need (sorted map if data is sparse?) go from 0 up, order of processing for blocks on same z level is not important. for each block get it's XY, check maxSettledXY if there's a block check it's Z, for all block XY coords, find maximal settled Z, and refs to all blocks that are directly under with that same Z. for the block set settledZ to Z+1, and for all those blocks add the block to 'supports' add block to settledOnZ[Z+1] for the second part, i can scan all the blocks, don't even need the settledOnZ, just check if it's 'supports' is empty ** DONE block type store z, and have 'settledZ', maybe with default -1? ** DONE coords type, func to get XY coords of the block ** DONE now i guess what? do i want a sorted map? or just map from height to blocks on that hight? let's read file, and calc max height present? i suppose funciton to read file could also be initially entered via test, right? ** DONE now go through the z levels, block by block, doing setting. i suppose i could organize setting methods around Space? it will store (settledOnZ) and (maxSettledOnXY) ** DONE [#A] when i settle single block. the maxSettledOnXY - should use (z + height) ** i can already imagine secon part? what is the most volume that can be disintegrated? or what? most volume is just all * part 1, wrong answer. i guess try to go, setting the input? block after block and try to check the calculations? what i want to check: how maxSettledOnXY works, how linking works. maybe i'll find a problem in few steps =C ** can't see anything just glancing around. maybe then trying to pick a block and track what's under it? * ok. let's try to brute force? for each block, remove it? create new space and try to settle it ** this is shit. why blocks move up? 2023/12/22 12:12:24 >>> starting for block [Block 1 - x:0-2, y:0-0, z:1, h:0, isSettled true] (supports [[Block 3 - x:0-0, y:0-2, z:3, h:0, isSettled true] [Block 4 - x:2-2, y:0-2, z:3, h:0, isSettled true] [Block 3 - x:0-0, y:0-2, z:2, h:0, isSettled true] [Block 4 - x:2-2, y:0-2, z:2, h:0, isSettled true]]) 2023/12/22 12:12:24 block [Block 2 - x:0-2, y:2-2, z:2, h:0, isSettled true] moved from 1 to 2 2023/12/22 12:12:24 block [Block 3 - x:0-0, y:0-2, z:3, h:0, isSettled true] moved from 2 to 3 2023/12/22 12:12:24 block [Block 4 - x:2-2, y:0-2, z:3, h:0, isSettled true] moved from 2 to 3 2023/12/22 12:12:24 block [Block 5 - x:0-2, y:1-1, z:4, h:0, isSettled true] moved from 3 to 4 2023/12/22 12:12:24 block [Block 6 - x:1-1, y:1-1, z:5, h:1, isSettled true] moved from 4 to 5 2023/12/22 12:12:24 for block [Block 1 - x:0-2, y:0-0, z:1, h:0, isSettled true] new space has 5 moved * ok. brute force with copying slices worked. now i want to debug. for each brick, when there is 0 falling, i want to check what are it's surroundings ** my initial was : 567 ** checking example of badly determined: >> for block [Block 291 - x:6-8, y:7-7, z:75, h:0, isSettled false] checking under coord {X:6 Y:7}. found under [Block 698 - x:6-8, y:7-7, z:35, h:0, isSettled true]. ( 'overriding' ) with 35 ; maxZ 35 directly supporting blocks are [[Block 698 - x:6-8, y:7-7, z:35, h:0, isSettled true]] checking under coord {X:7 Y:7}. found under [Block 698 - x:6-8, y:7-7, z:35, h:0, isSettled true]. ( 'adding' ) with 35 ; maxZ 35 directly supporting blocks are [[Block 698 - x:6-8, y:7-7, z:35, h:0, isSettled true] [Block 698 - x:6-8, y:7-7, z:35, h:0, isSettled true]] checking under coord {X:8 Y:7}. found under [Block 698 - x:6-8, y:7-7, z:35, h:0, isSettled true]. ( 'adding' ) with 35 ; maxZ 35 directly supporting blocks are [[Block 698 - x:6-8, y:7-7, z:35, h:0, isSettled true] [Block 698 - x:6-8, y:7-7, z:35, h:0, isSettled true] [Block 698 - x:6-8, y:7-7, z:35, h:0, isSettled true]] >> after settring block [Block 291 - x:6-8, y:7-7, z:36, h:0, isSettled true]. supported by [[Block 698 - x:6-8, y:7-7, z:35, h:0, isSettled true] [Block 698 - x:6-8, y:7-7, z:35, h:0, isSettled true] [Block 698 - x:6-8, y:7-7, z:35, h:0, isSettled true]] ** ouch. duplicates in slices. because there's no easy set thingy not doing this was my bug. #+begin_src go slices.SortFunc(block.SupportedBy, func(a *Block, b *Block) int { return cmp.Compare(a.NameNum, b.NameNum) }) block.SupportedBy = slices.Compact(block.SupportedBy) #+end_src