An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
I found some hits in Copilot finished the code
using System;
using System.Collections.Generic;
using System.Linq;
public class Summary
{
public int Parent { get; set; }
public int Number { get; set; }
public int Cnts { get; set; }
}
public class Program
{
public static void Main(string[] args)
{
var summaries = new List<Summary>
{
new Summary { Parent = 60, Number = 2, Cnts = 2 },
new Summary { Parent = 60, Number = 3, Cnts = 1},
new Summary { Parent = 60, Number = 5, Cnts = 1},
new Summary { Parent = 90, Number = 2, Cnts = 1 },
new Summary { Parent = 90, Number = 3, Cnts = 2},
new Summary { Parent = 90, Number = 5, Cnts = 1}
};
// Create a dictionary to group summaries by Parent and Number
var newSummaries = new List<Summary>(summaries);
// Count the number of newSummaries where Parent is not equal to summaries.Parent
// Count the number of distinct parents in newSummaries where Parent is not equal to summaries.Parent and Number matches
var filtergroups = new List<Summary>();
foreach (var summary in summaries)
{
int count = 0; int countm = 0;
var distinctNewParents = newSummaries
.Where(ns => ns.Parent != summary.Parent)
.Select(ns => ns.Parent)
.Distinct();
foreach (var parent in distinctNewParents)
{
count++;
}
//
var distinctParentsmatch = newSummaries
.Where(ns => ns.Parent != summary.Parent && ns.Number == summary.Number)
.Select(ns => ns.Parent)
.Distinct();
var distinctParents = new HashSet<int>();
foreach (var parentx in distinctParentsmatch)
{
distinctParents.Add(parentx);
}
countm = distinctParents.Count;
if (count == countm)
{
filtergroups.Add(new Summary { Parent = summary.Parent, Number = summary.Number, Cnts = summary.Cnts });
}
}
// Print the filtergroups
if (filtergroups.Any())
{
Console.WriteLine("Filtered groups:");
foreach (var fg in filtergroups)
{
Console.WriteLine($"Parent: {fg.Parent}, Number: {fg.Number}, Cnts: {fg.Cnts}");
}
}
else
{
Console.WriteLine("The list is empty.");
}
}
}