Advent of Code 2022 day 7 

I chose to use a tree data structure. I spent yesterday writing my own tree implementation and fighting with the borrow checker in #rust. Then, before going to bed, I looked online to see how others wrote the tree data structure in rust and I found a post that explained how trees are pain in rust. Of course, I see someone else's solution for AOC day 7 in the comments of the post which used a reverse lookup hash table - a much better solution.

re: Advent of Code 2022 day 7 

Anyways, here is the blog post. It's a good read:
https://dev.to/deciduously/no-more-tears-no-more-knots-arena-allocated-trees-in-rust-44k6

I also posted my solution using rust's indextree library for trees:

https://git.sr.ht/~anjan/advent2022/tree/main/item/day7

I dont think I needed to traverse through the tree 3 times - I probably could of done it in 1-2 traversal(s). I probably shouldve used a reverse lookup hash table but I didnt want to use a spoiler =P
Follow

re: Advent of Code 2022 day 7 

@anjan I like the arena idea. I solved it using Rc<RefCell<>> this time, but I will look for opportunities to use the arena solution.

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.