I'm working on this puzzle https://www.codingame.com/ide/puzzle/skynet-revolution-episode-2
In this puzzle i have to block an agent from reaching nodes in a network, by each turn selecting a connection that I want to cut. I can only cut connections directly connected to a gateway.
I have a list of gateways List<Node>
gateways.
I already have initialized each node with a List<Node>
Connections that contains the direct neighbors
Since gateways can be connected to more than one node, I am interested in the nodes that are exactly 1 node away from the gateways, so I can identify which one of those nodes (lets call them exitNodes) the agent is closest to.
How do I transform the list of gateways into a list of exit nodes? I tried
List<Node> exitNodes = gateways.Select(gw => gw.Connections).Select(node => node);
and this
List<Node> exitNodes = gateways.Select(gw => gw.Connections.Select(node => node));
I get the error
error CS0266: Cannot implicitly convert type
System.Collections.Generic.IEnumerable<System.Collections.Generic.List<Node>>' to
System.Collections.Generic.List'. An explicit conversion exists (are you missing a cast?)