Feladatok és megoldásaik hozzáadása

This commit is contained in:
Digi
2025-02-26 19:43:54 +01:00
commit 2d3a3b5498
31 changed files with 1765 additions and 0 deletions

View File

@@ -0,0 +1,188 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
public static class Karakterek
{
public static List<char> KarakterekList = new List<char>();
public static void ReadDataFromFile(string path)
{
KarakterekList = File.ReadAllText(path).ToCharArray().ToList();
}
public static List<char> LongestStringWithTwoCharactersOnly()
{
if (KarakterekList.Count < 2)
return new List<char>();
List<char> currentBestCharacterSequence = new List<char>();
List<char> currentCharacterSequence = new List<char>();
char firstChar = KarakterekList[0];
char secondChar = KarakterekList[1];
currentCharacterSequence.Add(firstChar);
currentCharacterSequence.Add(secondChar);
for (int i = 2; i < KarakterekList.Count; i++)
{
char item = KarakterekList[i];
if (item == firstChar || item == secondChar)
{
currentCharacterSequence.Add(item);
}
else
{
if (currentCharacterSequence.Count > currentBestCharacterSequence.Count)
{
currentBestCharacterSequence = new List<char>(currentCharacterSequence);
}
firstChar = currentCharacterSequence[currentCharacterSequence.Count - 1];
secondChar = item;
currentCharacterSequence.Clear();
currentCharacterSequence.Add(firstChar);
currentCharacterSequence.Add(secondChar);
}
}
if (currentCharacterSequence.Count > currentBestCharacterSequence.Count)
{
currentBestCharacterSequence = currentCharacterSequence;
}
return currentBestCharacterSequence;
}
public static int CountABCSequences(string input)
{
int count = 0;
for (int i = 0; i < input.Length; i++)
{
if (input[i] == 'a')
{
for (int j = i + 1; j < input.Length; j++)
{
if (input[j] == 'b')
{
for (int k = j + 1; k < input.Length; k++)
{
if (input[k] == 'c')
{
count++;
}
}
}
}
}
}
return count;
}
public static int TotalDistanceTraveled(string input){
int x = 0;
int y = 0;
for (int i = 0; i < input.Length; i++)
{
if (input[i] == 'b')
{
x++;
}
else if (input[i] == 'd')
{
x--;
}
else if (input[i] == 'a')
{
y++;
}
else if (input[i] == 'c')
{
y--;
}
}
return (int)Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
}
}
public static class Szoveg{
public static List<string> fullTextInListOfString = new List<string>();
public static List<string> wordsWithUniqeCharactersOnly = new List<string>();
public static void ReadDataFromFile(string path)
{
var lines = File.ReadAllText(path).Split(new string[] { Environment.NewLine }, StringSplitOptions.None).ToList();
foreach (var line in lines)
{
var allStringsInLine = line.Split(' ');
foreach (var str in allStringsInLine)
{
fullTextInListOfString.Add(str);
}
}
}
public static List<string> WordsWithUniqeCharactersOnly()
{
foreach (var word in fullTextInListOfString)
{
if (word.Distinct().Count() == word.Length)
{
wordsWithUniqeCharactersOnly.Add(word);
}
}
return wordsWithUniqeCharactersOnly;
}
public static string LongestStringWithUniqueCharacters()
{
return wordsWithUniqeCharactersOnly.OrderByDescending(s => s.Length).First();
}
}
public class Program
{
public static void Main(string[] args)
{
Karakterek.ReadDataFromFile(@"..\karsor.txt");
//System.Console.WriteLine($"{Karakterek.KarakterekList.Count}");
// feladat 1 a
/*
var longestStringWithTwoCharactersOnly = Karakterek.LongestStringWithTwoCharactersOnly();
var karakterek = longestStringWithTwoCharactersOnly.Distinct().OrderBy(c => c).ToArray();
int longestStringWithTwoCharactersOnlyLength = longestStringWithTwoCharactersOnly.Count;
System.Console.WriteLine($"{karakterek[0]}{karakterek[1]}{longestStringWithTwoCharactersOnlyLength}");
*/
// feladat 1 b
// ez az input változó volt használva a b és a c részben is
//string input = new string(Karakterek.KarakterekList.ToArray());
//System.Console.WriteLine($"{Karakterek.CountABCSequences(input)}");
// feladat 1 c
//System.Console.WriteLine($"{Karakterek.TotalDistanceTraveled(input)}");
// feladat 2 a
Szoveg.ReadDataFromFile(@"..\szoveg.txt");
Szoveg.wordsWithUniqeCharactersOnly = Szoveg.WordsWithUniqeCharactersOnly();
System.Console.WriteLine($"{Szoveg.LongestStringWithUniqueCharacters()}");
}
}

View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v9.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v9.0": {
"Program/1.0.0": {
"runtime": {
"Program.dll": {}
}
}
}
},
"libraries": {
"Program/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net9.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "9.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Program")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Program")]
[assembly: System.Reflection.AssemblyTitleAttribute("Program")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@@ -0,0 +1 @@
17a31eb238f6f175e91f757bce7478ca3439291fdf71caa540b0d35a4a757b14

View File

@@ -0,0 +1,15 @@
is_global = true
build_property.TargetFramework = net9.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Program
build_property.ProjectDir = E:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 9.0
build_property.EnableCodeStyleSeverity =

View File

@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

View File

@@ -0,0 +1 @@
994355595e6d8516655760be3cd67da1c71aa921f3caa99233e6f9c4eb253af7

View File

@@ -0,0 +1,14 @@
E:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\bin\Debug\net9.0\Program.exe
E:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\bin\Debug\net9.0\Program.deps.json
E:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\bin\Debug\net9.0\Program.runtimeconfig.json
E:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\bin\Debug\net9.0\Program.dll
E:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\bin\Debug\net9.0\Program.pdb
E:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\obj\Debug\net9.0\Program.GeneratedMSBuildEditorConfig.editorconfig
E:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\obj\Debug\net9.0\Program.AssemblyInfoInputs.cache
E:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\obj\Debug\net9.0\Program.AssemblyInfo.cs
E:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\obj\Debug\net9.0\Program.csproj.CoreCompileInputs.cache
E:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\obj\Debug\net9.0\Program.dll
E:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\obj\Debug\net9.0\refint\Program.dll
E:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\obj\Debug\net9.0\Program.pdb
E:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\obj\Debug\net9.0\Program.genruntimeconfig.cache
E:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\obj\Debug\net9.0\ref\Program.dll

Binary file not shown.

View File

@@ -0,0 +1 @@
ec5aef107619cf514071397c5ff593bd138d87eb40c2063670b11375de2d8f47

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,73 @@
{
"format": 1,
"restore": {
"E:\\Házi\\13.osztály\\Neumann_Verseny\\fordulo_1\\Program\\Program.csproj": {}
},
"projects": {
"E:\\Házi\\13.osztály\\Neumann_Verseny\\fordulo_1\\Program\\Program.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "E:\\Házi\\13.osztály\\Neumann_Verseny\\fordulo_1\\Program\\Program.csproj",
"projectName": "Program",
"projectPath": "E:\\Házi\\13.osztály\\Neumann_Verseny\\fordulo_1\\Program\\Program.csproj",
"packagesPath": "C:\\Users\\Marci\\.nuget\\packages\\",
"outputPath": "E:\\Házi\\13.osztály\\Neumann_Verseny\\fordulo_1\\Program\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\Marci\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.200"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.200/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Marci\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.13.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\Marci\.nuget\packages\" />
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View File

@@ -0,0 +1,79 @@
{
"version": 3,
"targets": {
"net9.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net9.0": []
},
"packageFolders": {
"C:\\Users\\Marci\\.nuget\\packages\\": {},
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "E:\\Házi\\13.osztály\\Neumann_Verseny\\fordulo_1\\Program\\Program.csproj",
"projectName": "Program",
"projectPath": "E:\\Házi\\13.osztály\\Neumann_Verseny\\fordulo_1\\Program\\Program.csproj",
"packagesPath": "C:\\Users\\Marci\\.nuget\\packages\\",
"outputPath": "E:\\Házi\\13.osztály\\Neumann_Verseny\\fordulo_1\\Program\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\Marci\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.200"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.200/PortableRuntimeIdentifierGraph.json"
}
}
}
}

View File

@@ -0,0 +1,8 @@
{
"version": 2,
"dgSpecHash": "ETkpdKREBtU=",
"success": true,
"projectFilePath": "E:\\Házi\\13.osztály\\Neumann_Verseny\\fordulo_1\\Program\\Program.csproj",
"expectedPackageFiles": [],
"logs": []
}