added sol for feladat 1
This commit is contained in:
parent
63a0218e9d
commit
8a8c57969a
fordulo_3/Program
.vs/Program
CopilotIndices/17.13.431.34963
FileContentIndex
24ae940c-d3e2-4622-89b4-afe0c30a3e02.vsidx6bc59fa7-74d6-421a-ae29-d9171104353f.vsidx9e11f8a1-a5a9-47df-be9a-ce8aca28cc71.vsidxa54afe52-e372-4ea3-81dc-3f89b4266538.vsidxab132887-542c-4edf-ac0b-0251699605d4.vsidxb3d64b05-42b2-41db-add4-3980079fb73e.vsidx
copilot-chat/f9c248b7/sessions
v17
bin/Debug
obj/Debug
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.
Binary file not shown.
|
@ -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": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}");
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -40,9 +40,9 @@
|
|||
## 3. Forduló
|
||||
|
||||
### 1. feladat
|
||||
- a: ``
|
||||
- b: ``
|
||||
- c: ``
|
||||
- a: `187`
|
||||
- b: `42`
|
||||
- c: `40`
|
||||
|
||||
### 2. feladat
|
||||
- `837799|524`
|
||||
|
|
Loading…
Reference in New Issue
Block a user