diff --git a/fordulo_3/Program/.vs/Program/CopilotIndices/17.13.431.34963/CodeChunks.db b/fordulo_3/Program/.vs/Program/CopilotIndices/17.13.431.34963/CodeChunks.db index 081d929..721d05a 100644 Binary files a/fordulo_3/Program/.vs/Program/CopilotIndices/17.13.431.34963/CodeChunks.db and b/fordulo_3/Program/.vs/Program/CopilotIndices/17.13.431.34963/CodeChunks.db differ diff --git a/fordulo_3/Program/.vs/Program/CopilotIndices/17.13.431.34963/SemanticSymbols.db b/fordulo_3/Program/.vs/Program/CopilotIndices/17.13.431.34963/SemanticSymbols.db index d578a75..33d071e 100644 Binary files a/fordulo_3/Program/.vs/Program/CopilotIndices/17.13.431.34963/SemanticSymbols.db and b/fordulo_3/Program/.vs/Program/CopilotIndices/17.13.431.34963/SemanticSymbols.db differ diff --git a/fordulo_3/Program/.vs/Program/FileContentIndex/03558ee9-6c41-41f3-ad68-b09a2d95a29e.vsidx b/fordulo_3/Program/.vs/Program/FileContentIndex/03558ee9-6c41-41f3-ad68-b09a2d95a29e.vsidx new file mode 100644 index 0000000..67de093 Binary files /dev/null and b/fordulo_3/Program/.vs/Program/FileContentIndex/03558ee9-6c41-41f3-ad68-b09a2d95a29e.vsidx differ diff --git a/fordulo_3/Program/.vs/Program/FileContentIndex/9c7cb05b-f4e5-44ad-8957-e9f7be36d2c8.vsidx b/fordulo_3/Program/.vs/Program/FileContentIndex/9c7cb05b-f4e5-44ad-8957-e9f7be36d2c8.vsidx deleted file mode 100644 index 84e0ebe..0000000 Binary files a/fordulo_3/Program/.vs/Program/FileContentIndex/9c7cb05b-f4e5-44ad-8957-e9f7be36d2c8.vsidx and /dev/null differ diff --git a/fordulo_3/Program/.vs/Program/FileContentIndex/a700aa66-caff-4d72-90c9-2cec60b33973.vsidx b/fordulo_3/Program/.vs/Program/FileContentIndex/a700aa66-caff-4d72-90c9-2cec60b33973.vsidx deleted file mode 100644 index 70aef67..0000000 Binary files a/fordulo_3/Program/.vs/Program/FileContentIndex/a700aa66-caff-4d72-90c9-2cec60b33973.vsidx and /dev/null differ diff --git a/fordulo_3/Program/.vs/Program/FileContentIndex/bf2be457-47fd-4c05-95ff-13b06b0d4062.vsidx b/fordulo_3/Program/.vs/Program/FileContentIndex/bf2be457-47fd-4c05-95ff-13b06b0d4062.vsidx new file mode 100644 index 0000000..a31cc94 Binary files /dev/null and b/fordulo_3/Program/.vs/Program/FileContentIndex/bf2be457-47fd-4c05-95ff-13b06b0d4062.vsidx differ diff --git a/fordulo_3/Program/.vs/Program/FileContentIndex/e1f6c6f7-dd66-4685-bede-ddf5e040a381.vsidx b/fordulo_3/Program/.vs/Program/FileContentIndex/e1f6c6f7-dd66-4685-bede-ddf5e040a381.vsidx new file mode 100644 index 0000000..c44dd7c Binary files /dev/null and b/fordulo_3/Program/.vs/Program/FileContentIndex/e1f6c6f7-dd66-4685-bede-ddf5e040a381.vsidx differ diff --git a/fordulo_3/Program/.vs/Program/copilot-chat/f9c248b7/sessions/60af910b-f53a-4808-9b09-d87c835f0707 b/fordulo_3/Program/.vs/Program/copilot-chat/f9c248b7/sessions/60af910b-f53a-4808-9b09-d87c835f0707 index ccc7347..0d93501 100644 Binary files a/fordulo_3/Program/.vs/Program/copilot-chat/f9c248b7/sessions/60af910b-f53a-4808-9b09-d87c835f0707 and b/fordulo_3/Program/.vs/Program/copilot-chat/f9c248b7/sessions/60af910b-f53a-4808-9b09-d87c835f0707 differ diff --git a/fordulo_3/Program/.vs/Program/v17/.suo b/fordulo_3/Program/.vs/Program/v17/.suo index b5b323e..f562391 100644 Binary files a/fordulo_3/Program/.vs/Program/v17/.suo and b/fordulo_3/Program/.vs/Program/v17/.suo differ diff --git a/fordulo_3/Program/.vs/Program/v17/DocumentLayout.backup.json b/fordulo_3/Program/.vs/Program/v17/DocumentLayout.backup.json index b447ecf..629360a 100644 --- a/fordulo_3/Program/.vs/Program/v17/DocumentLayout.backup.json +++ b/fordulo_3/Program/.vs/Program/v17/DocumentLayout.backup.json @@ -7,8 +7,8 @@ "RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" }, { - "AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|e:\\h\u00E1zi\\13.oszt\u00E1ly\\neumann_verseny\\fordulo_3\\program\\permutationgenerator.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", - "RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:permutationgenerator.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + "AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|e:\\h\u00E1zi\\13.oszt\u00E1ly\\neumann_verseny\\fordulo_3\\program\\virus.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:virus.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" } ], "DocumentGroupContainers": [ @@ -18,21 +18,8 @@ "DocumentGroups": [ { "DockedWidth": 200, - "SelectedChildIndex": 2, + "SelectedChildIndex": 0, "Children": [ - { - "$type": "Document", - "DocumentIndex": 1, - "Title": "PermutationGenerator.cs", - "DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\PermutationGenerator.cs", - "RelativeDocumentMoniker": "PermutationGenerator.cs", - "ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\PermutationGenerator.cs", - "RelativeToolTip": "PermutationGenerator.cs", - "ViewState": "AgIAAAAAAAAAAAAAAAAAABMAAAA8AAAAAAAAAA==", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2025-03-12T17:31:40.758Z", - "EditorCaption": "" - }, { "$type": "Document", "DocumentIndex": 0, @@ -41,10 +28,23 @@ "RelativeDocumentMoniker": "Program.cs", "ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs", "RelativeToolTip": "Program.cs", - "ViewState": "AgIAAAMAAAAAAAAAAAAwwBQAAAA6AAAAAAAAAA==", + "ViewState": "AgIAABwAAAAAAAAAAAAIwCcAAAAiAAAAAAAAAA==", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", "WhenOpened": "2025-03-12T12:54:16.847Z", "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 1, + "Title": "Virus.cs", + "DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Virus.cs", + "RelativeDocumentMoniker": "Virus.cs", + "ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Virus.cs", + "RelativeToolTip": "Virus.cs", + "ViewState": "AgIAAAAAAAAAAAAAAAAAADIAAAABAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2025-03-13T16:14:18.948Z", + "EditorCaption": "" } ] } diff --git a/fordulo_3/Program/.vs/Program/v17/DocumentLayout.json b/fordulo_3/Program/.vs/Program/v17/DocumentLayout.json index b447ecf..740caba 100644 --- a/fordulo_3/Program/.vs/Program/v17/DocumentLayout.json +++ b/fordulo_3/Program/.vs/Program/v17/DocumentLayout.json @@ -7,8 +7,8 @@ "RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" }, { - "AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|e:\\h\u00E1zi\\13.oszt\u00E1ly\\neumann_verseny\\fordulo_3\\program\\permutationgenerator.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", - "RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:permutationgenerator.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + "AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|e:\\h\u00E1zi\\13.oszt\u00E1ly\\neumann_verseny\\fordulo_3\\program\\virus.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:virus.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" } ], "DocumentGroupContainers": [ @@ -18,21 +18,8 @@ "DocumentGroups": [ { "DockedWidth": 200, - "SelectedChildIndex": 2, + "SelectedChildIndex": 0, "Children": [ - { - "$type": "Document", - "DocumentIndex": 1, - "Title": "PermutationGenerator.cs", - "DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\PermutationGenerator.cs", - "RelativeDocumentMoniker": "PermutationGenerator.cs", - "ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\PermutationGenerator.cs", - "RelativeToolTip": "PermutationGenerator.cs", - "ViewState": "AgIAAAAAAAAAAAAAAAAAABMAAAA8AAAAAAAAAA==", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2025-03-12T17:31:40.758Z", - "EditorCaption": "" - }, { "$type": "Document", "DocumentIndex": 0, @@ -41,10 +28,23 @@ "RelativeDocumentMoniker": "Program.cs", "ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs", "RelativeToolTip": "Program.cs", - "ViewState": "AgIAAAMAAAAAAAAAAAAwwBQAAAA6AAAAAAAAAA==", + "ViewState": "AgIAAD8AAAAAAAAAAAAcwCcAAAAiAAAAAAAAAA==", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", "WhenOpened": "2025-03-12T12:54:16.847Z", "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 1, + "Title": "Virus.cs", + "DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Virus.cs", + "RelativeDocumentMoniker": "Virus.cs", + "ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Virus.cs", + "RelativeToolTip": "Virus.cs", + "ViewState": "AgIAAAMAAAAAAAAAAAAAADIAAAABAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2025-03-13T16:14:18.948Z", + "EditorCaption": "" } ] } diff --git a/fordulo_3/Program/Feladat3.cs b/fordulo_3/Program/Feladat3.cs new file mode 100644 index 0000000..a1ba842 --- /dev/null +++ b/fordulo_3/Program/Feladat3.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Program +{ + class Feladat3 + { + static void Feladat_3() + { + List<int> primes = new List<int>(); + + for (int i = 1000; i < 10000; i++) + { + if (IsPrime(i)) + { + primes.Add(i); + string result = string.Join("", GetSortedDigits(i)); + Console.WriteLine($"({i},{result}),"); + } + } + + List<int[]> primesWithDecimalValuesOrdered = new List<int[]>(); + + foreach (int i in primes) + { + primesWithDecimalValuesOrdered.Add(GetSortedDigits(i)); + } + + var keyValuePairs = primesWithDecimalValuesOrdered + .GroupBy(x => x, new IntArrayComparer()) + .Select(g => new KeyValuePair<int[], int>(g.Key, g.Count())) + .Where(kvp => kvp.Value >= 6) + .ToList().Count(); + + // Print the key-value pairs + /* + foreach (var kvp in keyValuePairs) + { + Console.WriteLine($"Key: {string.Join("", kvp.Key)}, Value: {kvp.Value}"); + } + */ + + Console.WriteLine(keyValuePairs); + + + + + + int[] digits = { 0, 1, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9 }; + int length = 4; + + PermutationGenerator generator = new PermutationGenerator(); + generator.GeneratePermutations(digits, length); + //generator.PrintGroupedPermutations(); + + // Get groups with at least 6 primes + var groupsWithAtLeast6Primes = generator.GroupedPermutations + .Where(group => group.Value.Count(permutation => IsPrime(int.Parse(string.Join("", permutation)))) >= 6) + .ToList(); + + // Print the groups with at least 6 primes + foreach (var group in groupsWithAtLeast6Primes) + { + Console.WriteLine($"Group: {group.Key}"); + foreach (var permutation in group.Value) + { + Console.WriteLine(string.Join("", permutation)); + } + Console.WriteLine(); + } + } + + static int[] GetSortedDigits(int number) + { + // Convert the number to a string to access each digit + string numberString = number.ToString(); + + // Convert each character to an integer + int[] digits = numberString.Select(c => int.Parse(c.ToString())).ToArray(); + + // Sort the array of integers + Array.Sort(digits); + + return digits; + } + + static bool IsPrime(int number) + { + if (number <= 1) return false; + if (number == 2) return true; + if (number % 2 == 0) return false; + + int boundary = (int)Math.Floor(Math.Sqrt(number)); + + for (int i = 3; i <= boundary; i += 2) + { + if (number % i == 0) return false; + } + + return true; + } + } + + class IntArrayComparer : IEqualityComparer<int[]> + { + public bool Equals(int[] x, int[] y) + { + if (x == null || y == null) + return false; + + if (x.Length != y.Length) + return false; + + for (int i = 0; i < x.Length; i++) + { + if (x[i] != y[i]) + return false; + } + + return true; + } + + public int GetHashCode(int[] obj) + { + if (obj == null) + return 0; + + int hash = 17; + foreach (int i in obj) + { + hash = hash * 31 + i; + } + + return hash; + } + } +} + diff --git a/fordulo_3/Program/Program.cs b/fordulo_3/Program/Program.cs index e2294c2..4bdab15 100644 --- a/fordulo_3/Program/Program.cs +++ b/fordulo_3/Program/Program.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -8,135 +9,127 @@ namespace Program { class Program { + public static Dictionary<int, List<int>> Contacts = new Dictionary<int, List<int>>(); + public static HashSet<int> InfectedPeople = new HashSet<int>(); + static void Main(string[] args) { - List<int> primes = new List<int>(); + string path = $@"../../../forrasok/elek.txt"; - for (int i = 1000; i < 10000; i++) + var data = File.ReadAllLines(path); + + foreach (var item in data) { - if (IsPrime(i)) + string[] nums = item.Split(' '); + int infector = Convert.ToInt32(nums[0]); + int infected = Convert.ToInt32(nums[1]); + + if (Contacts.ContainsKey(infector)) { - primes.Add(i); - string result = string.Join("", GetSortedDigits(i)); - Console.WriteLine($"({i},{result}),"); + Contacts[infector].Add(infected); + } + else + { + Contacts[infector] = new List<int> { infected }; } } - List<int[]> primesWithDecimalValuesOrdered = new List<int[]>(); + Virus rootVirus = new Virus(2); + InfectedPeople.Clear(); // Clear the set before starting the spread + InfectedPeople.Add(2); // Add the root virus to the infected set + SpreadBFS(rootVirus, 2); + //Spread(rootVirus, 9); - foreach (int i in primes) + //rootVirus.PrintInfectionTreeWithDepth(2, 0, "->"); + rootVirus.PrintInfectionTree(); + + Console.WriteLine(InfectedPeople.Count); + } + + + public static void SpreadBFS(Virus rootVirus, int maxDepth) + { + Queue<(Virus virus, int depth)> queue = new Queue<(Virus virus, int depth)>(); + queue.Enqueue((rootVirus, 0)); + + while (queue.Count > 0) { - primesWithDecimalValuesOrdered.Add(GetSortedDigits(i)); - } + var (currentVirus, currentDepth) = queue.Dequeue(); - var keyValuePairs = primesWithDecimalValuesOrdered - .GroupBy(x => x, new IntArrayComparer()) - .Select(g => new KeyValuePair<int[], int>(g.Key, g.Count())) - .Where(kvp => kvp.Value >= 6) - .ToList().Count(); - - // Print the key-value pairs - /* - foreach (var kvp in keyValuePairs) - { - Console.WriteLine($"Key: {string.Join("", kvp.Key)}, Value: {kvp.Value}"); - } - */ - - Console.WriteLine(keyValuePairs); - - - - - - int[] digits = { 0, 1, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9 }; - int length = 4; - - PermutationGenerator generator = new PermutationGenerator(); - generator.GeneratePermutations(digits, length); - //generator.PrintGroupedPermutations(); - - // Get groups with at least 6 primes - var groupsWithAtLeast6Primes = generator.GroupedPermutations - .Where(group => group.Value.Count(permutation => IsPrime(int.Parse(string.Join("", permutation)))) >= 6) - .ToList(); - - // Print the groups with at least 6 primes - foreach (var group in groupsWithAtLeast6Primes) - { - Console.WriteLine($"Group: {group.Key}"); - foreach (var permutation in group.Value) + if (currentDepth >= maxDepth) { - Console.WriteLine(string.Join("", permutation)); + continue; + } + + if (Contacts.ContainsKey(currentVirus.Name)) + { + foreach (var contact in Contacts[currentVirus.Name]) + { + if (!InfectedPeople.Contains(contact)) + { + Virus newInfected = new Virus(contact, currentDepth + 1); + currentVirus.Infect(newInfected); + InfectedPeople.Add(contact); // Mark as infected + queue.Enqueue((newInfected, currentDepth + 1)); + } + } + } + + // Check if the current virus should be healed + if (currentDepth - currentVirus.InfectionTurn >= 8) + { + InfectedPeople.Remove(currentVirus.Name); } - Console.WriteLine(); } - - } - static int[] GetSortedDigits(int number) + public static void Spread(Virus virus, int maxDepth, int currentDepth = 0) { - // Convert the number to a string to access each digit - string numberString = number.ToString(); - - // Convert each character to an integer - int[] digits = numberString.Select(c => int.Parse(c.ToString())).ToArray(); - - // Sort the array of integers - Array.Sort(digits); - - return digits; - } - - static bool IsPrime(int number) - { - if (number <= 1) return false; - if (number == 2) return true; - if (number % 2 == 0) return false; - - int boundary = (int)Math.Floor(Math.Sqrt(number)); - - for (int i = 3; i <= boundary; i += 2) + if (currentDepth >= maxDepth) { - if (number % i == 0) return false; + return; } - return true; - } - } - - class IntArrayComparer : IEqualityComparer<int[]> - { - public bool Equals(int[] x, int[] y) - { - if (x == null || y == null) - return false; - - if (x.Length != y.Length) - return false; - - for (int i = 0; i < x.Length; i++) + if (Contacts.ContainsKey(virus.Name)) { - if (x[i] != y[i]) - return false; - } + foreach (var contact in Contacts[virus.Name]) + { + if (!InfectedPeople.Contains(contact)) + { + Virus newInfected = new Virus(contact); + virus.Infect(newInfected); + InfectedPeople.Add(contact); // Mark as infected + Spread(newInfected, maxDepth, currentDepth + 1); + } else + { + Virus newInfected = new Virus(contact); + virus.Infect(newInfected); + //InfectedPeople.Add(contact); // Mark as infected + Spread(newInfected, maxDepth, currentDepth + 1); + } - return true; + } + } } - public int GetHashCode(int[] obj) + /* + public static void Spread(Virus virus) { - if (obj == null) - return 0; - - int hash = 17; - foreach (int i in obj) + if (Contacts.ContainsKey(virus.Name)) { - hash = hash * 31 + i; + foreach (var contact in Contacts[virus.Name]) + { + if (!InfectedPeople.Contains(contact)) + { + Virus newInfected = new Virus(contact); + virus.Infect(newInfected); + InfectedPeople.Add(contact); // Mark as infected + Spread(newInfected); + } + } } - - return hash; } + */ + } } diff --git a/fordulo_3/Program/Program.csproj b/fordulo_3/Program/Program.csproj index 803e089..535183e 100644 --- a/fordulo_3/Program/Program.csproj +++ b/fordulo_3/Program/Program.csproj @@ -43,10 +43,12 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="Feladat3.cs" /> <Compile Include="PermutationGenerator.cs" /> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Sorozat.cs" /> + <Compile Include="Virus.cs" /> </ItemGroup> <ItemGroup> <None Include="App.config" /> diff --git a/fordulo_3/Program/Virus.cs b/fordulo_3/Program/Virus.cs new file mode 100644 index 0000000..2494dea --- /dev/null +++ b/fordulo_3/Program/Virus.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; + +namespace Program +{ + public class Virus + { + public int Name { get; set; } + public Virus Parent { get; set; } + public List<Virus> Infected { get; private set; } + public int InfectionTurn { get; set; } + + public Virus(int name, int infectionTurn = 0) + { + Name = name; + Infected = new List<Virus>(); + InfectionTurn = infectionTurn; + } + + public Virus(int name, Virus parent, int infectionTurn = 0) : this(name, infectionTurn) + { + Parent = parent; + } + + public void Infect(Virus virus) + { + virus.Parent = this; + Infected.Add(virus); + } + + public void PrintInfectionTree(string indent = "") + { + Console.WriteLine($"{indent}Virus {Name}"); + foreach (var infected in Infected) + { + infected.PrintInfectionTree(indent + " "); + } + } + + public void PrintInfectionTreeWithDepth(int maxDepth, int currentDepth = 0, string indent = "") + { + if (currentDepth > maxDepth) return; + + Console.WriteLine($"{indent}Virus {Name}"); + foreach (var infected in Infected) + { + infected.PrintInfectionTreeWithDepth(maxDepth, currentDepth + 1, indent + " "); + } + } + } +} \ No newline at end of file diff --git a/fordulo_3/Program/bin/Debug/Program.exe b/fordulo_3/Program/bin/Debug/Program.exe index 84d4dd3..ccfc29f 100644 Binary files a/fordulo_3/Program/bin/Debug/Program.exe and b/fordulo_3/Program/bin/Debug/Program.exe differ diff --git a/fordulo_3/Program/bin/Debug/Program.pdb b/fordulo_3/Program/bin/Debug/Program.pdb index 7ded619..4f93824 100644 Binary files a/fordulo_3/Program/bin/Debug/Program.pdb and b/fordulo_3/Program/bin/Debug/Program.pdb differ diff --git a/fordulo_3/Program/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/fordulo_3/Program/obj/Debug/DesignTimeResolveAssemblyReferences.cache new file mode 100644 index 0000000..2f8a9d3 Binary files /dev/null and b/fordulo_3/Program/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/fordulo_3/Program/obj/Debug/Program.csproj.CoreCompileInputs.cache b/fordulo_3/Program/obj/Debug/Program.csproj.CoreCompileInputs.cache index 470f2e3..5e9e8fc 100644 --- a/fordulo_3/Program/obj/Debug/Program.csproj.CoreCompileInputs.cache +++ b/fordulo_3/Program/obj/Debug/Program.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -0f60ae438c65b1815603680249bf9a5d03a307c39118102277870be2ddb77ab4 +ca659b73ef474311d403419aa47bed331b1360853dc02e88fb5dee915c0be9c6 diff --git a/fordulo_3/Program/obj/Debug/Program.exe b/fordulo_3/Program/obj/Debug/Program.exe index 84d4dd3..ccfc29f 100644 Binary files a/fordulo_3/Program/obj/Debug/Program.exe and b/fordulo_3/Program/obj/Debug/Program.exe differ diff --git a/fordulo_3/Program/obj/Debug/Program.pdb b/fordulo_3/Program/obj/Debug/Program.pdb index 7ded619..4f93824 100644 Binary files a/fordulo_3/Program/obj/Debug/Program.pdb and b/fordulo_3/Program/obj/Debug/Program.pdb differ diff --git a/fordulo_3/forrasok/elek.txt b/fordulo_3/forrasok/elek.txt new file mode 100644 index 0000000..f706d1f --- /dev/null +++ b/fordulo_3/forrasok/elek.txt @@ -0,0 +1,1500 @@ +1 16 +1 36 +1 48 +1 51 +1 59 +1 92 +1 147 +1 206 +2 18 +2 27 +2 133 +2 170 +2 192 +2 230 +3 6 +3 24 +3 58 +3 90 +3 91 +3 94 +3 131 +3 135 +3 144 +3 157 +3 169 +3 191 +3 195 +3 206 +3 237 +4 65 +4 90 +4 140 +4 146 +4 179 +4 194 +4 195 +4 196 +4 202 +4 217 +4 221 +4 224 +5 9 +5 11 +5 21 +5 37 +5 87 +5 90 +5 164 +5 168 +5 172 +5 255 +6 9 +6 20 +6 36 +6 48 +6 56 +6 58 +6 82 +6 121 +6 158 +6 164 +6 171 +6 213 +6 232 +7 31 +7 95 +7 105 +7 106 +7 158 +7 167 +7 179 +7 192 +7 235 +7 253 +8 14 +8 60 +8 82 +8 128 +8 129 +8 145 +8 162 +8 188 +8 192 +8 208 +8 211 +8 219 +9 35 +9 48 +9 75 +9 100 +9 131 +9 167 +9 180 +9 225 +9 229 +9 236 +9 252 +10 20 +10 47 +10 52 +10 90 +10 131 +10 145 +10 169 +10 210 +10 211 +10 214 +10 243 +11 67 +11 122 +11 142 +11 144 +11 148 +11 193 +11 223 +11 253 +11 264 +12 34 +12 41 +12 59 +12 110 +12 154 +12 170 +12 172 +12 199 +12 220 +12 226 +12 234 +12 264 +13 47 +13 98 +13 116 +13 134 +13 158 +13 159 +13 167 +13 168 +13 195 +13 237 +13 238 +13 239 +14 28 +14 74 +14 102 +14 112 +14 119 +14 141 +14 160 +14 166 +14 193 +14 205 +14 213 +15 63 +15 68 +15 70 +15 128 +15 165 +15 168 +15 170 +15 219 +15 228 +15 230 +15 247 +16 30 +16 55 +16 94 +16 135 +16 137 +16 168 +16 171 +16 228 +16 251 +17 39 +17 66 +17 112 +17 133 +17 135 +17 197 +17 217 +17 238 +18 42 +18 53 +18 55 +18 77 +18 85 +18 87 +18 127 +18 186 +18 191 +18 198 +18 203 +18 215 +18 255 +19 52 +19 76 +19 104 +19 153 +19 159 +19 180 +19 193 +19 227 +19 265 +20 27 +20 66 +20 81 +20 104 +20 146 +20 148 +20 193 +20 206 +20 223 +20 243 +21 36 +21 41 +21 64 +21 70 +21 95 +21 119 +21 171 +21 177 +21 238 +21 242 +21 255 +21 261 +22 25 +22 32 +22 59 +22 74 +22 95 +22 178 +22 185 +22 194 +22 196 +22 258 +23 27 +23 32 +23 56 +23 62 +23 83 +23 107 +23 119 +23 123 +23 124 +23 142 +23 214 +23 216 +23 228 +24 27 +24 43 +24 81 +24 103 +24 117 +24 135 +24 196 +24 247 +24 261 +25 68 +25 69 +25 71 +25 78 +25 109 +25 159 +25 169 +25 226 +25 241 +26 32 +26 54 +26 90 +26 131 +26 180 +26 204 +26 257 +27 36 +27 46 +27 87 +27 144 +27 170 +27 175 +27 218 +27 223 +27 240 +28 49 +28 97 +28 129 +28 158 +28 162 +28 188 +28 206 +28 232 +28 238 +28 245 +28 251 +29 35 +29 44 +29 70 +29 84 +29 135 +29 143 +29 186 +29 197 +29 218 +29 258 +30 46 +30 49 +30 110 +30 114 +30 167 +30 173 +30 247 +31 68 +31 77 +31 134 +31 174 +31 222 +31 239 +31 256 +32 39 +32 76 +32 96 +32 105 +32 130 +32 162 +32 181 +32 225 +32 264 +33 53 +33 72 +33 74 +33 145 +33 181 +33 188 +33 222 +33 226 +33 245 +34 55 +34 72 +34 75 +34 189 +34 204 +34 244 +35 74 +35 78 +35 147 +35 179 +35 199 +36 41 +36 51 +36 159 +36 183 +36 192 +36 200 +36 203 +36 220 +36 221 +36 248 +37 39 +37 42 +37 44 +37 55 +37 80 +37 147 +37 165 +37 177 +37 190 +37 204 +37 251 +38 40 +38 77 +38 97 +38 103 +38 105 +38 120 +38 139 +38 164 +38 190 +38 241 +38 247 +38 265 +39 115 +39 131 +39 157 +39 215 +39 216 +40 45 +40 72 +40 82 +40 95 +40 137 +40 162 +40 203 +40 206 +40 256 +41 96 +41 127 +41 136 +41 137 +41 167 +41 186 +41 235 +41 256 +41 264 +42 69 +42 71 +42 78 +42 106 +42 115 +42 127 +42 153 +42 166 +42 174 +42 259 +42 260 +43 49 +43 58 +43 81 +43 97 +43 99 +43 104 +43 111 +43 128 +43 139 +43 144 +43 152 +43 193 +43 208 +43 242 +43 247 +43 248 +44 59 +44 62 +44 64 +44 81 +44 116 +44 130 +44 132 +44 157 +44 218 +44 230 +44 231 +45 74 +45 91 +45 116 +45 172 +45 174 +45 190 +45 208 +45 211 +45 225 +45 248 +45 261 +46 53 +46 54 +46 135 +46 158 +46 161 +46 171 +46 173 +46 179 +46 203 +46 222 +46 225 +46 255 +46 265 +47 52 +47 69 +47 95 +47 120 +47 178 +47 180 +47 220 +47 263 +48 97 +48 139 +48 156 +48 163 +48 164 +48 175 +48 184 +48 205 +48 263 +49 67 +49 122 +49 158 +49 176 +49 193 +49 239 +49 244 +49 246 +50 70 +50 92 +50 100 +50 132 +50 150 +50 184 +50 194 +50 202 +50 241 +51 58 +51 74 +51 99 +51 114 +51 116 +51 161 +51 168 +51 180 +51 226 +52 89 +52 109 +52 174 +52 206 +52 210 +52 251 +53 61 +53 94 +53 129 +53 131 +53 164 +53 180 +53 195 +53 196 +53 200 +53 225 +53 264 +54 70 +54 72 +54 99 +54 124 +54 127 +54 139 +54 143 +54 178 +55 82 +55 131 +55 135 +55 140 +55 231 +55 232 +55 233 +55 238 +55 241 +55 249 +55 263 +56 59 +56 63 +56 91 +56 105 +56 106 +56 108 +56 165 +56 217 +56 265 +57 60 +57 105 +57 171 +57 198 +57 226 +58 83 +58 96 +58 172 +58 173 +58 236 +58 264 +59 79 +59 87 +59 137 +59 163 +59 219 +59 221 +60 105 +60 171 +60 198 +60 216 +60 245 +60 257 +61 92 +61 109 +61 110 +61 125 +61 144 +61 185 +61 202 +61 212 +61 224 +61 237 +61 262 +62 71 +62 76 +62 93 +62 111 +62 173 +62 178 +62 186 +62 202 +62 245 +62 249 +63 115 +63 149 +63 151 +63 160 +63 168 +63 173 +63 180 +63 183 +63 226 +63 228 +63 256 +64 73 +64 78 +64 128 +64 134 +64 140 +64 230 +64 248 +65 112 +65 123 +65 124 +65 153 +65 163 +65 164 +65 168 +66 116 +66 157 +66 167 +66 171 +66 205 +66 228 +66 248 +66 249 +66 264 +67 70 +67 78 +67 79 +67 105 +67 111 +67 115 +67 146 +67 151 +67 154 +67 155 +67 190 +67 212 +68 70 +68 76 +68 92 +68 110 +68 122 +68 169 +68 186 +68 189 +68 218 +68 259 +68 261 +69 84 +69 100 +69 107 +69 120 +69 127 +69 184 +69 213 +69 264 +70 112 +70 156 +70 166 +70 178 +70 223 +70 247 +71 74 +71 105 +71 123 +71 124 +71 142 +71 162 +71 172 +71 175 +71 177 +71 191 +71 193 +71 220 +71 242 +72 119 +72 141 +72 147 +72 150 +72 170 +72 203 +72 215 +72 216 +72 223 +72 227 +72 247 +73 142 +73 148 +73 203 +73 209 +73 215 +73 253 +74 103 +74 114 +74 115 +74 117 +74 131 +74 260 +74 263 +75 76 +75 92 +75 99 +75 146 +75 167 +75 169 +75 195 +75 237 +75 248 +75 260 +76 91 +76 117 +76 152 +76 170 +77 101 +77 104 +77 105 +77 135 +77 139 +77 142 +77 175 +77 187 +77 196 +77 201 +78 79 +78 88 +78 92 +78 128 +78 132 +78 182 +78 194 +78 212 +78 233 +78 260 +78 264 +79 87 +79 117 +79 122 +79 123 +79 147 +79 201 +79 203 +79 233 +79 237 +80 94 +80 119 +80 160 +80 164 +80 173 +80 218 +80 223 +80 226 +80 230 +81 115 +81 154 +81 166 +81 185 +81 198 +81 203 +81 225 +81 258 +81 264 +82 89 +82 100 +82 165 +82 227 +82 243 +82 259 +83 86 +83 103 +83 122 +83 138 +83 144 +83 156 +83 160 +83 176 +83 180 +83 184 +83 202 +83 234 +83 235 +83 236 +83 261 +84 87 +84 92 +84 108 +84 111 +84 132 +84 136 +84 160 +84 167 +84 181 +84 195 +84 196 +84 203 +85 86 +85 116 +85 193 +85 195 +85 196 +85 203 +85 222 +85 226 +85 263 +86 87 +86 101 +86 107 +86 131 +86 194 +87 100 +87 103 +87 105 +87 116 +87 186 +87 240 +88 121 +88 130 +88 138 +88 149 +88 205 +88 219 +88 250 +88 251 +88 262 +89 95 +89 101 +89 127 +89 192 +89 238 +89 252 +89 256 +90 97 +90 118 +90 133 +90 162 +90 181 +90 203 +90 225 +91 108 +91 128 +91 130 +91 134 +91 195 +91 248 +92 156 +92 173 +92 187 +92 228 +92 261 +93 94 +93 124 +93 152 +93 206 +93 211 +93 218 +94 96 +94 104 +94 118 +94 124 +95 112 +95 151 +95 162 +95 176 +95 185 +95 223 +96 120 +96 125 +96 143 +96 150 +96 161 +96 171 +96 190 +96 198 +96 214 +96 219 +97 98 +97 198 +97 206 +98 154 +98 167 +98 201 +98 213 +98 262 +99 121 +99 138 +99 152 +99 156 +99 170 +99 200 +99 224 +99 226 +99 238 +99 261 +99 265 +100 104 +100 106 +100 121 +100 137 +100 148 +100 190 +100 208 +100 238 +100 245 +101 107 +101 113 +101 130 +101 133 +101 203 +101 227 +101 228 +101 241 +101 253 +102 117 +102 142 +102 155 +102 168 +102 207 +102 210 +102 246 +103 113 +103 116 +103 127 +103 177 +103 197 +103 227 +104 115 +104 166 +104 183 +104 198 +104 207 +104 241 +105 108 +105 112 +105 120 +105 139 +105 143 +105 147 +105 187 +105 197 +105 244 +106 119 +106 127 +106 138 +106 184 +106 213 +106 265 +107 172 +107 174 +107 213 +107 260 +108 120 +108 156 +108 168 +108 172 +108 200 +108 202 +108 221 +108 225 +109 118 +109 121 +109 136 +109 138 +109 173 +109 177 +109 221 +110 165 +110 223 +110 249 +111 147 +111 194 +111 195 +111 213 +111 224 +111 256 +112 124 +112 128 +112 145 +112 179 +112 183 +112 195 +112 209 +112 253 +113 129 +113 136 +113 175 +113 179 +113 210 +113 237 +114 127 +114 192 +114 202 +114 234 +114 240 +115 116 +115 130 +115 207 +115 222 +115 232 +115 239 +115 241 +116 173 +116 196 +116 197 +116 230 +117 132 +117 133 +117 162 +117 169 +117 243 +118 123 +118 155 +118 219 +118 228 +118 233 +118 263 +119 121 +119 129 +119 135 +119 141 +119 147 +119 177 +119 181 +119 197 +119 231 +119 257 +120 126 +120 136 +120 145 +120 178 +120 209 +120 258 +121 135 +121 155 +121 166 +122 127 +122 132 +122 144 +122 152 +122 158 +122 165 +122 199 +122 244 +122 259 +122 261 +123 128 +123 133 +123 148 +123 164 +123 224 +123 250 +123 264 +124 145 +124 153 +124 167 +124 214 +124 234 +124 237 +125 132 +125 137 +125 149 +125 216 +125 225 +125 244 +126 135 +126 138 +126 139 +126 194 +126 252 +126 254 +127 138 +127 165 +127 216 +128 189 +128 191 +128 212 +128 226 +128 235 +128 248 +128 260 +129 176 +129 223 +129 228 +129 231 +129 245 +129 246 +130 138 +130 158 +130 160 +130 168 +130 186 +130 195 +130 199 +130 202 +130 240 +131 163 +131 174 +131 182 +131 214 +131 226 +131 232 +131 245 +131 259 +132 157 +132 200 +132 215 +132 226 +132 239 +133 146 +133 161 +133 163 +133 167 +133 211 +133 220 +134 143 +134 182 +134 194 +134 198 +134 205 +134 213 +134 216 +134 240 +134 258 +135 145 +135 149 +135 187 +136 138 +136 138 +136 162 +136 182 +136 225 +136 242 +136 246 +137 176 +137 185 +137 189 +137 197 +137 211 +137 234 +138 153 +138 172 +138 178 +138 205 +138 217 +138 251 +138 255 +138 256 +139 163 +139 174 +139 215 +139 242 +139 258 +140 172 +140 236 +140 239 +141 155 +141 159 +141 180 +141 185 +141 261 +142 181 +142 185 +142 206 +143 149 +143 154 +143 178 +143 208 +143 210 +143 220 +143 222 +143 236 +143 256 +144 190 +144 205 +144 211 +144 224 +144 251 +144 265 +145 147 +145 151 +145 219 +145 254 +145 262 +146 157 +146 169 +146 175 +146 217 +146 229 +146 246 +147 193 +147 194 +147 204 +147 232 +147 249 +148 158 +148 200 +148 209 +148 254 +148 263 +149 160 +149 164 +149 229 +150 151 +150 179 +150 213 +150 265 +151 195 +151 211 +151 214 +151 215 +151 226 +151 243 +151 258 +152 170 +152 175 +153 172 +153 185 +153 195 +153 217 +153 249 +154 163 +154 180 +154 216 +154 236 +154 254 +155 156 +155 174 +155 260 +155 262 +156 158 +156 242 +156 244 +156 250 +157 198 +157 218 +157 219 +157 244 +157 251 +157 261 +158 166 +158 173 +158 179 +158 187 +158 197 +158 206 +158 237 +158 253 +159 166 +159 168 +159 176 +159 177 +159 199 +159 237 +159 259 +160 182 +160 195 +160 199 +160 209 +160 221 +160 243 +161 195 +161 211 +161 260 +162 176 +162 212 +162 249 +163 167 +163 196 +164 173 +164 182 +164 202 +165 176 +165 182 +165 194 +165 214 +165 220 +166 167 +166 206 +167 196 +167 251 +168 207 +168 220 +168 234 +168 244 +168 259 +169 181 +170 180 +170 252 +171 210 +171 242 +171 261 +171 262 +172 199 +172 207 +172 244 +173 184 +173 259 +174 198 +174 209 +174 222 +174 253 +175 193 +175 198 +175 258 +175 260 +176 195 +176 229 +176 243 +177 236 +178 179 +178 214 +178 224 +178 227 +178 242 +178 248 +179 191 +179 195 +179 207 +179 215 +180 194 +180 199 +180 212 +180 244 +181 191 +181 192 +181 194 +181 219 +181 224 +181 237 +182 188 +182 223 +182 234 +182 242 +182 260 +183 184 +183 189 +183 193 +183 213 +183 214 +183 223 +183 225 +183 239 +183 247 +183 266 +184 195 +184 218 +184 222 +184 238 +184 249 +185 197 +185 236 +185 262 +186 192 +186 209 +186 224 +186 229 +186 242 +186 250 +187 194 +187 201 +187 221 +187 224 +189 208 +189 210 +189 220 +189 226 +190 218 +191 198 +191 201 +191 224 +191 229 +191 233 +193 198 +193 210 +193 217 +194 219 +194 236 +194 255 +195 238 +196 205 +196 231 +196 247 +197 204 +197 219 +197 244 +198 210 +198 236 +198 246 +199 205 +199 235 +199 243 +199 244 +199 249 +199 251 +200 225 +200 227 +200 255 +201 224 +201 228 +201 232 +201 253 +201 263 +202 213 +202 235 +202 256 +202 259 +203 206 +203 253 +204 208 +204 211 +204 213 +204 215 +204 248 +204 260 +205 218 +205 238 +205 243 +206 221 +206 223 +206 228 +206 236 +206 246 +207 238 +207 240 +207 253 +207 264 +208 220 +208 222 +208 229 +208 233 +209 223 +209 228 +210 234 +210 236 +210 254 +211 256 +212 231 +212 237 +212 252 +213 228 +214 233 +215 231 +215 235 +215 242 +216 240 +217 219 +217 224 +217 231 +217 239 +217 262 +218 241 +219 227 +221 241 +221 247 +221 251 +222 231 +222 265 +223 246 +224 230 +224 254 +224 257 +225 260 +225 264 +227 252 +229 245 +229 254 +230 243 +230 245 +230 246 +230 264 +230 265 +231 247 +231 251 +231 257 +232 233 +232 237 +233 266 +234 250 +234 263 +235 236 +235 239 +235 263 +236 244 +237 260 +238 255 +238 261 +238 264 +239 250 +239 253 +241 265 +243 249 +244 260 +245 258 +246 248 +249 256 +255 261 +256 258 +259 261 diff --git a/megoldasok.md b/megoldasok.md index 5d302b9..dbaabba 100644 --- a/megoldasok.md +++ b/megoldasok.md @@ -49,7 +49,7 @@ ### 3. feladat - a: `42` -- b: `` +- b: `296962999629` ### 4. feladat - a: ``