made some progress
This commit is contained in:
parent
f92b3d93ef
commit
125039f7af
fordulo_3
Program
.vs/Program
CopilotIndices/17.13.431.34963
FileContentIndex
03558ee9-6c41-41f3-ad68-b09a2d95a29e.vsidx9c7cb05b-f4e5-44ad-8957-e9f7be36d2c8.vsidxa700aa66-caff-4d72-90c9-2cec60b33973.vsidxbf2be457-47fd-4c05-95ff-13b06b0d4062.vsidxe1f6c6f7-dd66-4685-bede-ddf5e040a381.vsidx
copilot-chat/f9c248b7/sessions
v17
bin/Debug
obj/Debug
forrasok
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -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": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
141
fordulo_3/Program/Feladat3.cs
Normal file
141
fordulo_3/Program/Feladat3.cs
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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" />
|
||||
|
|
51
fordulo_3/Program/Virus.cs
Normal file
51
fordulo_3/Program/Virus.cs
Normal file
|
@ -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 + " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
|||
0f60ae438c65b1815603680249bf9a5d03a307c39118102277870be2ddb77ab4
|
||||
ca659b73ef474311d403419aa47bed331b1360853dc02e88fb5dee915c0be9c6
|
||||
|
|
Binary file not shown.
Binary file not shown.
1500
fordulo_3/forrasok/elek.txt
Normal file
1500
fordulo_3/forrasok/elek.txt
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -49,7 +49,7 @@
|
|||
|
||||
### 3. feladat
|
||||
- a: `42`
|
||||
- b: ``
|
||||
- b: `296962999629`
|
||||
|
||||
### 4. feladat
|
||||
- a: ``
|
||||
|
|
Loading…
Reference in New Issue
Block a user