added another Doboz implementation

This commit is contained in:
Digi 2025-03-15 11:14:41 +01:00
parent 8a8c57969a
commit 4b27a19904
29 changed files with 440 additions and 4 deletions

Binary file not shown.

View File

@ -0,0 +1,53 @@
{
"Version": 1,
"WorkspaceRootPath": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Doboz\\DobozFeladat\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{63095089-49CB-410A-876C-75573E045D7D}|DobozFeladat.csproj|e:\\h\u00E1zi\\13.oszt\u00E1ly\\neumann_verseny\\fordulo_3\\doboz\\dobozfeladat\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{63095089-49CB-410A-876C-75573E045D7D}|DobozFeladat.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{63095089-49CB-410A-876C-75573E045D7D}|DobozFeladat.csproj|E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Doboz\\DobozFeladat\\box.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{63095089-49CB-410A-876C-75573E045D7D}|DobozFeladat.csproj|solutionrelative:box.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 1,
"Children": [
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "Box.cs",
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Doboz\\DobozFeladat\\Box.cs",
"RelativeDocumentMoniker": "Box.cs",
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Doboz\\DobozFeladat\\Box.cs",
"RelativeToolTip": "Box.cs",
"ViewState": "AgIAADEAAAAAAAAAAAAwwFkAAAAZAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-03-15T09:00:39.48Z"
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "Program.cs",
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Doboz\\DobozFeladat\\Program.cs",
"RelativeDocumentMoniker": "Program.cs",
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Doboz\\DobozFeladat\\Program.cs",
"RelativeToolTip": "Program.cs",
"ViewState": "AgIAACgAAAAAAAAAAAAcwE8AAABOAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-03-15T09:00:10.429Z",
"EditorCaption": ""
}
]
}
]
}
]
}

View File

@ -0,0 +1,53 @@
{
"Version": 1,
"WorkspaceRootPath": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Doboz\\DobozFeladat\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{63095089-49CB-410A-876C-75573E045D7D}|DobozFeladat.csproj|e:\\h\u00E1zi\\13.oszt\u00E1ly\\neumann_verseny\\fordulo_3\\doboz\\dobozfeladat\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{63095089-49CB-410A-876C-75573E045D7D}|DobozFeladat.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{63095089-49CB-410A-876C-75573E045D7D}|DobozFeladat.csproj|E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Doboz\\DobozFeladat\\box.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{63095089-49CB-410A-876C-75573E045D7D}|DobozFeladat.csproj|solutionrelative:box.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 1,
"Children": [
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "Box.cs",
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Doboz\\DobozFeladat\\Box.cs",
"RelativeDocumentMoniker": "Box.cs",
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Doboz\\DobozFeladat\\Box.cs",
"RelativeToolTip": "Box.cs",
"ViewState": "AgIAADEAAAAAAAAAAAAwwFkAAAAZAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-03-15T09:00:39.48Z"
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "Program.cs",
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Doboz\\DobozFeladat\\Program.cs",
"RelativeDocumentMoniker": "Program.cs",
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Doboz\\DobozFeladat\\Program.cs",
"RelativeToolTip": "Program.cs",
"ViewState": "AgIAACgAAAAAAAAAAAAcwD0AAAAwAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-03-15T09:00:10.429Z",
"EditorCaption": ""
}
]
}
]
}
]
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

View File

@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DobozFeladat
{
public class Box
{
public char Type { get; set; }
public bool IsDefected = false;
public Box Parent = null;
public Box Child = null;
public Box(char Type)
{
this.Type = Type;
}
public Box(char Type, bool IsDefected)
{
this.Type = Type;
this.IsDefected = IsDefected;
}
public bool AddedChild(Box newbox)
{
if (this.IsDefected)
{
if (this.Type == 'A' && newbox.Type == 'C')
{
SetChildParentProperties(newbox);
return true;
}
if (this.Type == 'B')
{
return false;
}
}
if (this.Child == null)
{
if (this.Type == 'A' && (newbox.Type == 'B' || newbox.Type == 'C'))
{
SetChildParentProperties(newbox);
return true;
}
if (this.Type == 'B' && newbox.Type == 'C')
{
SetChildParentProperties(newbox);
return true;
}
} else
{
return this.Child.AddedChild(newbox);
}
return false;
}
public void SetChildParentProperties(Box newbox)
{
this.Child = newbox;
newbox.Parent = this;
}
public bool ReadyForPackaging()
{
if (this.Child != null)
{
return this.Child.ReadyForPackaging();
}
if (this.Type == 'B' && this.IsDefected)
{
return true;
}
if (this.Type == 'C')
{
return true;
}
return false;
}
public string PrintBoxRecursively()
{
if (this.Child != null)
{
Console.Write(this.Type);
return this.Child.PrintBoxRecursively();
}
Console.WriteLine(this.Type);
return $"{this.Type}";
}
}
}

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{63095089-49CB-410A-876C-75573E045D7D}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>DobozFeladat</RootNamespace>
<AssemblyName>DobozFeladat</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Box.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35818.85 d17.13
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DobozFeladat", "DobozFeladat.csproj", "{63095089-49CB-410A-876C-75573E045D7D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{63095089-49CB-410A-876C-75573E045D7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{63095089-49CB-410A-876C-75573E045D7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{63095089-49CB-410A-876C-75573E045D7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{63095089-49CB-410A-876C-75573E045D7D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EC60653C-1EF4-439B-9161-E112EBF293ED}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace DobozFeladat
{
class Program
{
public static List<Box> Boxes = new List<Box>();
static void Main(string[] args)
{
string path = $@"../../../../../fordulo_3/forrasok/dobozok.txt";
char[] AllBoxes = File.ReadAllText(path).ToCharArray();
//char[] AllBoxes = { 'A','B','A','C', 'A','C','B','C','C','A'};
int ACount = 0;
int BCount = 0;
int MaximumLength = 0;
int TotalBoxPlaceUsed = 0;
foreach (char character in AllBoxes)
{
bool IsDefected = false;
if (character == 'A')
{
ACount++;
if (ACount % 25 == 0)
{
// switch to true for c || false for b
IsDefected = true;
}
}
if (character == 'B')
{
BCount++;
if (BCount % 25 == 0)
{
// switch to true for c || false for b
IsDefected = true;
}
}
Box box = new Box(character, IsDefected);
foreach (Box Place in Boxes)
{
if (Place.AddedChild(box))
{
break;
}
}
if (Boxes.Count > MaximumLength)
{
MaximumLength = Boxes.Count;
}
if (box.Parent == null)
{
Boxes.Add(box);
TotalBoxPlaceUsed++;
}
Boxes.RemoveAll(x => x.ReadyForPackaging());
}
int length = 0;
foreach (var Box in Boxes)
{
length += Box.PrintBoxRecursively().Count();
}
Console.WriteLine($"Maximum length needed: {length}");
Console.WriteLine($"Total box place needed: {TotalBoxPlaceUsed}");
}
}
}

View File

@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("DobozFeladat")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DobozFeladat")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("63095089-49cb-410a-876c-75573e045d7d")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

View File

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]

View File

@ -0,0 +1 @@
e1eea3c5164f556c505875c4ee5bd41aa3fa86547ec12881b072fa51cb713ad0

View File

@ -0,0 +1,14 @@
E:\Házi\13.osztály\Neumann_Verseny\Doboz\DobozFeladat\bin\Debug\DobozFeladat.exe.config
E:\Házi\13.osztály\Neumann_Verseny\Doboz\DobozFeladat\bin\Debug\DobozFeladat.exe
E:\Házi\13.osztály\Neumann_Verseny\Doboz\DobozFeladat\bin\Debug\DobozFeladat.pdb
E:\Házi\13.osztály\Neumann_Verseny\Doboz\DobozFeladat\obj\Debug\DobozFeladat.csproj.AssemblyReference.cache
E:\Házi\13.osztály\Neumann_Verseny\Doboz\DobozFeladat\obj\Debug\DobozFeladat.csproj.CoreCompileInputs.cache
E:\Házi\13.osztály\Neumann_Verseny\Doboz\DobozFeladat\obj\Debug\DobozFeladat.exe
E:\Házi\13.osztály\Neumann_Verseny\Doboz\DobozFeladat\obj\Debug\DobozFeladat.pdb
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Doboz\DobozFeladat\bin\Debug\DobozFeladat.exe.config
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Doboz\DobozFeladat\bin\Debug\DobozFeladat.exe
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Doboz\DobozFeladat\bin\Debug\DobozFeladat.pdb
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Doboz\DobozFeladat\obj\Debug\DobozFeladat.csproj.AssemblyReference.cache
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Doboz\DobozFeladat\obj\Debug\DobozFeladat.csproj.CoreCompileInputs.cache
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Doboz\DobozFeladat\obj\Debug\DobozFeladat.exe
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Doboz\DobozFeladat\obj\Debug\DobozFeladat.pdb

View File

@ -28,7 +28,7 @@
"RelativeDocumentMoniker": "Program.cs",
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs",
"RelativeToolTip": "Program.cs",
"ViewState": "AgIAAEgAAAAAAAAAAAAowGIAAABoAAAAAAAAAA==",
"ViewState": "AgIAAEgAAAAAAAAAAAAowGIAAABNAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-03-12T12:54:16.847Z",
"EditorCaption": ""

View File

@ -28,7 +28,7 @@
"RelativeDocumentMoniker": "Program.cs",
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs",
"RelativeToolTip": "Program.cs",
"ViewState": "AgIAAEgAAAAAAAAAAAAowGIAAABNAAAAAAAAAA==",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAGIAAABNAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-03-12T12:54:16.847Z",
"EditorCaption": ""
@ -43,8 +43,7 @@
"RelativeToolTip": "Doboz.cs",
"ViewState": "AgIAAAMAAAAAAAAAAAAkwA4AAAAJAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-03-14T09:40:24.572Z",
"EditorCaption": ""
"WhenOpened": "2025-03-14T09:40:24.572Z"
}
]
}