thanks for some people for pointing out an error in this video: symmetric difference (XOR) for sets is A\B union B\A, not intersection. the intersection would be empty. thanks to hyro in my discord server for this correction and also @michalbalcerek4442 in the comments!
My main language is PHP. After watching yours and other aoc-solvers' videos, I was really impressed by Python's data structures. So I did a very short research and found that PHP has a very neat basic extension for data structures: it has deque, set, queue, stack and so on, and those are properly implemented (and there's union and intersect for sets as well). It seems that having a single flexible hashmap-like data structure instead of an array is good enough for most PHP use cases, but it's nice to have a real tools in case if you know what to do with them.
The part2 is a pretty dumb problem. There is even a specific algorithm for it(Maximal Clique - Bron-Kerbosch Algorithm). Straight up a textbook problem. Idk that it exist tho. So it takes me awhile to come up with a solution. Abusing the fact that each node don't have that many neighbour. You don't even need to modify anything. Can just straight up copy paste the algorithm and auto solve. It was a reasonably nice problem if u don't know it exist. I mean it was solvable without needing to be a genius or knowing it exist. I kinda hope they stop asking a textbook problem. At least make it a part of small move to solve actual problem or required some modification instead of copy+paste+auto_solved. But it's not really a bad thing. I mean I learned something new. That's matter more than anything. But it's not that good for people who are competing for rank(not me so , it's whatever). Also GPT are very good at textbook/standard problem lol!
thanks for some people for pointing out an error in this video: symmetric difference (XOR) for sets is A\B union B\A, not intersection. the intersection would be empty. thanks to hyro in my discord server for this correction and also @michalbalcerek4442 in the comments!
nice ;-)
@15:16
conns = defaultdict(set)
names are string, you can use compare to eliminate multiple counting
if x < y < z and x in conns[z] ...
My main language is PHP. After watching yours and other aoc-solvers' videos, I was really impressed by Python's data structures. So I did a very short research and found that PHP has a very neat basic extension for data structures: it has deque, set, queue, stack and so on, and those are properly implemented (and there's union and intersect for sets as well). It seems that having a single flexible hashmap-like data structure instead of an array is good enough for most PHP use cases, but it's nice to have a real tools in case if you know what to do with them.
symdiff in maths is an up-pointing triangle/uppercase delta
And it's a union/sum not intersection as in the video, as the intersection of A\B and B\A is empty. AΔB = (A\B) u (B\A).
The part2 is a pretty dumb problem. There is even a specific algorithm for it(Maximal Clique - Bron-Kerbosch Algorithm). Straight up a textbook problem. Idk that it exist tho. So it takes me awhile to come up with a solution. Abusing the fact that each node don't have that many neighbour. You don't even need to modify anything. Can just straight up copy paste the algorithm and auto solve. It was a reasonably nice problem if u don't know it exist. I mean it was solvable without needing to be a genius or knowing it exist. I kinda hope they stop asking a textbook problem. At least make it a part of small move to solve actual problem or required some modification instead of copy+paste+auto_solved. But it's not really a bad thing. I mean I learned something new. That's matter more than anything. But it's not that good for people who are competing for rank(not me so , it's whatever). Also GPT are very good at textbook/standard problem lol!
You could do
```
req.add(neighbor)
search(neighbor, req)
req.remove(neighbor)
```
without copying the set.