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 721d05a..ae320c3 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 33d071e..25c70bb 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/24ae940c-d3e2-4622-89b4-afe0c30a3e02.vsidx b/fordulo_3/Program/.vs/Program/FileContentIndex/24ae940c-d3e2-4622-89b4-afe0c30a3e02.vsidx new file mode 100644 index 0000000..99cba02 Binary files /dev/null and b/fordulo_3/Program/.vs/Program/FileContentIndex/24ae940c-d3e2-4622-89b4-afe0c30a3e02.vsidx differ diff --git a/fordulo_3/Program/.vs/Program/FileContentIndex/6bc59fa7-74d6-421a-ae29-d9171104353f.vsidx b/fordulo_3/Program/.vs/Program/FileContentIndex/6bc59fa7-74d6-421a-ae29-d9171104353f.vsidx deleted file mode 100644 index ce3d5e5..0000000 Binary files a/fordulo_3/Program/.vs/Program/FileContentIndex/6bc59fa7-74d6-421a-ae29-d9171104353f.vsidx and /dev/null differ diff --git a/fordulo_3/Program/.vs/Program/FileContentIndex/9e11f8a1-a5a9-47df-be9a-ce8aca28cc71.vsidx b/fordulo_3/Program/.vs/Program/FileContentIndex/9e11f8a1-a5a9-47df-be9a-ce8aca28cc71.vsidx deleted file mode 100644 index 8fb2c6e..0000000 Binary files a/fordulo_3/Program/.vs/Program/FileContentIndex/9e11f8a1-a5a9-47df-be9a-ce8aca28cc71.vsidx and /dev/null differ diff --git a/fordulo_3/Program/.vs/Program/FileContentIndex/a54afe52-e372-4ea3-81dc-3f89b4266538.vsidx b/fordulo_3/Program/.vs/Program/FileContentIndex/a54afe52-e372-4ea3-81dc-3f89b4266538.vsidx new file mode 100644 index 0000000..70aef67 Binary files /dev/null and b/fordulo_3/Program/.vs/Program/FileContentIndex/a54afe52-e372-4ea3-81dc-3f89b4266538.vsidx differ diff --git a/fordulo_3/Program/.vs/Program/FileContentIndex/ab132887-542c-4edf-ac0b-0251699605d4.vsidx b/fordulo_3/Program/.vs/Program/FileContentIndex/ab132887-542c-4edf-ac0b-0251699605d4.vsidx deleted file mode 100644 index 506b171..0000000 Binary files a/fordulo_3/Program/.vs/Program/FileContentIndex/ab132887-542c-4edf-ac0b-0251699605d4.vsidx and /dev/null differ diff --git a/fordulo_3/Program/.vs/Program/FileContentIndex/b3d64b05-42b2-41db-add4-3980079fb73e.vsidx b/fordulo_3/Program/.vs/Program/FileContentIndex/b3d64b05-42b2-41db-add4-3980079fb73e.vsidx new file mode 100644 index 0000000..70aef67 Binary files /dev/null and b/fordulo_3/Program/.vs/Program/FileContentIndex/b3d64b05-42b2-41db-add4-3980079fb73e.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 fc3b65e..77adb78 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 960e9c3..e91fff6 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 521832a..3370991 100644 --- a/fordulo_3/Program/.vs/Program/v17/DocumentLayout.backup.json +++ b/fordulo_3/Program/.vs/Program/v17/DocumentLayout.backup.json @@ -1,13 +1,13 @@ { "Version": 1, - "WorkspaceRootPath": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\", + "WorkspaceRootPath": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\", "Documents": [ { - "AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|c:\\users\\szabomarton\\desktop\\verseny\\fordulo_3\\program\\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\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", "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|C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\doboz.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\\doboz.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", "RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:doboz.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" } ], @@ -18,33 +18,33 @@ "DocumentGroups": [ { "DockedWidth": 200, - "SelectedChildIndex": 1, + "SelectedChildIndex": 0, "Children": [ - { - "$type": "Document", - "DocumentIndex": 1, - "Title": "Doboz.cs", - "DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Doboz.cs", - "RelativeDocumentMoniker": "Doboz.cs", - "ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Doboz.cs", - "RelativeToolTip": "Doboz.cs", - "ViewState": "AgIAABMAAAAAAAAAAAAUwCIAAAA5AAAAAAAAAA==", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2025-03-14T09:40:24.572Z", - "EditorCaption": "" - }, { "$type": "Document", "DocumentIndex": 0, "Title": "Program.cs", - "DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Program.cs", + "DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs", "RelativeDocumentMoniker": "Program.cs", - "ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Program.cs", + "ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs", "RelativeToolTip": "Program.cs", - "ViewState": "AgIAAA8AAAAAAAAAAAAqwCQAAAAhAAAAAAAAAA==", + "ViewState": "AgIAAEgAAAAAAAAAAAAowGIAAABoAAAAAAAAAA==", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", "WhenOpened": "2025-03-12T12:54:16.847Z", "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 1, + "Title": "Doboz.cs", + "DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Doboz.cs", + "RelativeDocumentMoniker": "Doboz.cs", + "ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Doboz.cs", + "RelativeToolTip": "Doboz.cs", + "ViewState": "AgIAAAMAAAAAAAAAAAAkwA4AAAAJAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2025-03-14T09:40:24.572Z", + "EditorCaption": "" } ] } diff --git a/fordulo_3/Program/.vs/Program/v17/DocumentLayout.json b/fordulo_3/Program/.vs/Program/v17/DocumentLayout.json index 1160888..94b9000 100644 --- a/fordulo_3/Program/.vs/Program/v17/DocumentLayout.json +++ b/fordulo_3/Program/.vs/Program/v17/DocumentLayout.json @@ -1,13 +1,13 @@ { "Version": 1, - "WorkspaceRootPath": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\", + "WorkspaceRootPath": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\", "Documents": [ { - "AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|c:\\users\\szabomarton\\desktop\\verseny\\fordulo_3\\program\\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\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", "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|C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\doboz.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\\doboz.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", "RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:doboz.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" } ], @@ -18,33 +18,33 @@ "DocumentGroups": [ { "DockedWidth": 200, - "SelectedChildIndex": 1, + "SelectedChildIndex": 0, "Children": [ - { - "$type": "Document", - "DocumentIndex": 1, - "Title": "Doboz.cs", - "DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Doboz.cs", - "RelativeDocumentMoniker": "Doboz.cs", - "ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Doboz.cs", - "RelativeToolTip": "Doboz.cs", - "ViewState": "AgIAABMAAAAAAAAAAAAUwCIAAAA5AAAAAAAAAA==", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2025-03-14T09:40:24.572Z", - "EditorCaption": "" - }, { "$type": "Document", "DocumentIndex": 0, "Title": "Program.cs", - "DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Program.cs", + "DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs", "RelativeDocumentMoniker": "Program.cs", - "ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Program.cs", + "ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs", "RelativeToolTip": "Program.cs", - "ViewState": "AgIAAA8AAAAAAAAAAAAqwBgAAAAeAAAAAAAAAA==", + "ViewState": "AgIAAEgAAAAAAAAAAAAowGIAAABNAAAAAAAAAA==", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", "WhenOpened": "2025-03-12T12:54:16.847Z", "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 1, + "Title": "Doboz.cs", + "DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Doboz.cs", + "RelativeDocumentMoniker": "Doboz.cs", + "ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Doboz.cs", + "RelativeToolTip": "Doboz.cs", + "ViewState": "AgIAAAMAAAAAAAAAAAAkwA4AAAAJAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2025-03-14T09:40:24.572Z", + "EditorCaption": "" } ] } diff --git a/fordulo_3/Program/Doboz.cs b/fordulo_3/Program/Doboz.cs index 649e015..898f1fe 100644 --- a/fordulo_3/Program/Doboz.cs +++ b/fordulo_3/Program/Doboz.cs @@ -9,34 +9,9 @@ namespace Program internal class Doboz { public char Type { get; set; } - - public Doboz Children = null; - - public Doboz Parent = null; public Doboz(char Type) { this.Type = Type; } - - public void AddChildren(Doboz doboz) - { - doboz.Parent = this; - this.Children = doboz; - } - - public void PrintBoxContent(int indent = 0) - { - string indentStr = ""; - for (int i = 0; i < indent; i++) - { - indentStr += "->"; - } - - Console.WriteLine($"{indentStr}{this.Type}"); - if (this.Children != null) - { - this.Children.PrintBoxContent(indent + 1); - } - } } } diff --git a/fordulo_3/Program/Program.cs b/fordulo_3/Program/Program.cs index 8d922f1..f07e52e 100644 --- a/fordulo_3/Program/Program.cs +++ b/fordulo_3/Program/Program.cs @@ -9,48 +9,249 @@ namespace Program { class Program { - public static List<Doboz> Boxes = new List<Doboz>(); + //public static List<List<char>> Boxes = new List<List<char>>(); + public static List<List<(char, bool)>> Boxes = new List<List<(char, bool)>>(); static void Main(string[] args) { string path = "../../../forrasok/dobozok.txt"; var AllBoxes = File.ReadAllText(path).ToCharArray(); - foreach (var item in AllBoxes) + //TaskA(AllBoxes); + TaskBWithDefectiveBoxes(AllBoxes); + + } + /* + static void TaskA(char[] AllBoxes) + { + Boxes.Clear(); + + foreach (char character in AllBoxes) { - Doboz doboz = new Doboz(item); - foreach (var box in Boxes) + bool shouldIAddIt = true; + + foreach (var location in Boxes) { - if (doboz.Type == 'A') + if (CanContain(location.Last(), character)) { + location.Add(character); + shouldIAddIt = false; break; } - - if (box.Type == 'A' && box.Children == null) - { - if (doboz.Type == 'B' || doboz.Type == 'C') - { - box.AddChildren(doboz); - break; - } - } - - if (box.Type == 'B' && box.Children == null) - { - if (doboz.Type == 'C') - { - box.AddChildren(doboz); - break; - } - } } - Boxes.Add(doboz); + + if (shouldIAddIt) + { + Boxes.Add(new List<char> { character }); + } } - foreach (var item in Boxes) + Console.WriteLine($"Task A: Minimum number of wrapped packages: {Boxes.Count}"); + } + + */ + + static void TaskBWithDefectiveBoxes(char[] AllBoxes) + { + Boxes.Clear(); + int maxActiveLocations = 0; + int aCount = 0; + int bCount = 0; + + foreach (char character in AllBoxes) { - item.PrintBoxContent(); + bool shouldIAddIt = true; + bool isDefective = false; + + if (character == 'A') + { + aCount++; + if (aCount % 25 == 0) + { + isDefective = true; + } + } + else if (character == 'B') + { + bCount++; + if (bCount % 25 == 0) + { + isDefective = true; + } + } + + foreach (var location in Boxes) + { + if (CanContain(location.Last(), (character, isDefective))) + { + location.Add((character, isDefective)); + shouldIAddIt = false; + break; + } + } + + if (shouldIAddIt) + { + Boxes.Add(new List<(char, bool)> { (character, isDefective) }); + } + + // Remove wrapped locations (those containing 'C') + Boxes.RemoveAll(location => location.Any(box => box.Item1 == 'C')); + Boxes.RemoveAll(location => location.Any(box => box.Item1 == 'B' && box.Item2 == true)); + + maxActiveLocations = Math.Max(maxActiveLocations, Boxes.Count); + } + + Console.WriteLine($"Task B with Defective Boxes: Maximum number of active packing locations: {maxActiveLocations}"); + } + + static bool CanContain((char, bool) outer, (char, bool) inner) + { + char outerType = outer.Item1; + bool outerDefective = outer.Item2; + char innerType = inner.Item1; + bool innerDefective = inner.Item2; + + if (outerType == 'A') + { + if (outerDefective) + { + return innerType == 'C'; + } + else + { + return innerType == 'B' || innerType == 'C'; + } + } + if (outerType == 'B') + { + if (outerDefective) + { + return false; + } + else + { + return innerType == 'C'; + } + } + return false; + } + + /* + static void TaskB(char[] AllBoxes) + { + Boxes.Clear(); + int maxActiveLocations = 0; + + foreach (char character in AllBoxes) + { + bool shouldIAddIt = true; + + foreach (var location in Boxes) + { + if (CanContain(location.Last(), character)) + { + location.Add(character); + shouldIAddIt = false; + break; + } + } + + if (shouldIAddIt) + { + Boxes.Add(new List<char> { character }); + } + + // Remove wrapped locations (those containing 'C') + Boxes.RemoveAll(location => location.Contains('C')); + + maxActiveLocations = Math.Max(maxActiveLocations, Boxes.Count); + } + + Console.WriteLine($"Task B: Maximum number of active packing locations: {maxActiveLocations}"); + } + + static bool CanContain(char outer, char inner) + { + if (outer == 'A' && (inner == 'B' || inner == 'C')) + return true; + if (outer == 'B' && inner == 'C') + return true; + return false; + } + + */ + + static void Feladat2(string path, char[] AllBoxes) + { + foreach (var character in AllBoxes) + { + } } + /* + static void Feladat1(string path, char[] AllBoxes) + { + + foreach (char character in AllBoxes) + { + if (character == 'A') + { + Boxes.Add(new List<char> { 'A' }); + continue; + } + + bool shouldIAddIt = false; + int counter = 0; + foreach (var hely in Boxes) + { + if (character == 'B') + { + if (!hely.Contains('B') && !hely.Contains('C')) + { + hely.Add('B'); + break; + } + + } + + if (character == 'C') + { + if (!hely.Contains('C')) + { + hely.Add('C'); + break; + } + } + counter++; + } + + if (counter == Boxes.Count) + { + shouldIAddIt = true; + } + + if (shouldIAddIt) + { + Boxes.Add(new List<char> { character }); + } + } + + + + foreach (var item in Boxes) + { + foreach (char character in item) + { + Console.Write($"{character}"); + } + Console.WriteLine(); + } + + Console.WriteLine($"1. feladat a: {Boxes.Count}"); + } + + */ + } } diff --git a/fordulo_3/Program/bin/Debug/Program.exe b/fordulo_3/Program/bin/Debug/Program.exe index cbe0fd0..b53b325 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 3d393de..e9f3bcb 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/DesignTimeResolveAssemblyReferencesInput.cache b/fordulo_3/Program/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 5b9e3f7..388e3ef 100644 Binary files a/fordulo_3/Program/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/fordulo_3/Program/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/fordulo_3/Program/obj/Debug/Program.exe b/fordulo_3/Program/obj/Debug/Program.exe index cbe0fd0..b53b325 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 3d393de..e9f3bcb 100644 Binary files a/fordulo_3/Program/obj/Debug/Program.pdb and b/fordulo_3/Program/obj/Debug/Program.pdb differ diff --git a/megoldasok.md b/megoldasok.md index e39d48e..084c533 100644 --- a/megoldasok.md +++ b/megoldasok.md @@ -40,9 +40,9 @@ ## 3. Forduló ### 1. feladat -- a: `` -- b: `` -- c: `` +- a: `187` +- b: `42` +- c: `40` ### 2. feladat - `837799|524`