Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - "1->2"
- - "1->2->3"
- - "1->2->3->4"
- - "5->6"
- - "5->6->7"
- - "5->6->7->8"
- "1->2->3->4"
- "5->6->7->8"
- public class Program
- {
- public static void Main(string[] args)
- {
- List<(string, i)> flattenedPaths = new List<(string, i)>
- {
- ("1->2", 0)
- ("1->2->3", 1)
- ("1->2->3->4", 2)
- ("5->6", 3)
- ("5->6->7", 4)
- ("5->6->7->8", 5)
- };
- IEnumerable<string> uniquePaths = GetUniquePaths(flattenedPaths);
- }
- public static IEnumerable<(string, int)> GetUniquePaths(List<(string, int)> Paths)
- {
- for (int i = 0; i < Paths.Count; i++)
- {
- bool doesMatchContain = Paths.Skip(i)
- .Any(x => x.Item1.Contains(Paths[i].Item1));
- if (!doesMatchContain)
- yield return Paths[i];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement