Projektdateien hinzufügen.
This commit is contained in:
parent
e6aae68233
commit
df11d118a9
27
Kalender.sln
Normal file
27
Kalender.sln
Normal file
|
@ -0,0 +1,27 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32929.385
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kalender", "Kalender\Kalender.csproj", "{7F620304-6022-4939-A6D9-01A9BBC907A9}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Projektmappenelemente", "Projektmappenelemente", "{4955BCA5-D3BC-4562-BC34-070B7214820F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7F620304-6022-4939-A6D9-01A9BBC907A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7F620304-6022-4939-A6D9-01A9BBC907A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7F620304-6022-4939-A6D9-01A9BBC907A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7F620304-6022-4939-A6D9-01A9BBC907A9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {42F2B407-DB71-47A7-918C-B80AD8F0F273}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
6
Kalender/App.config
Normal file
6
Kalender/App.config
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
57
Kalender/Kalender.csproj
Normal file
57
Kalender/Kalender.csproj
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?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>{7F620304-6022-4939-A6D9-01A9BBC907A9}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Kalender</RootNamespace>
|
||||
<AssemblyName>Kalender</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</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="day1.cs" />
|
||||
<Compile Include="day2.cs" />
|
||||
<Compile Include="day3.cs" />
|
||||
<Compile Include="day5.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
17
Kalender/Program.cs
Normal file
17
Kalender/Program.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Kalender
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
day5.getMoveLine();
|
||||
Console.ReadKey();
|
||||
}
|
||||
}
|
||||
}
|
36
Kalender/Properties/AssemblyInfo.cs
Normal file
36
Kalender/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
// die einer Assembly zugeordnet sind.
|
||||
[assembly: AssemblyTitle("Kalender")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Kalender")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
|
||||
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
|
||||
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
||||
[assembly: Guid("7f620304-6022-4939-a6d9-01a9bbc907a9")]
|
||||
|
||||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
//
|
||||
// Hauptversion
|
||||
// Nebenversion
|
||||
// Buildnummer
|
||||
// Revision
|
||||
//
|
||||
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||
// indem Sie "*" wie unten gezeigt eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
56
Kalender/day1.cs
Normal file
56
Kalender/day1.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Kalender
|
||||
{
|
||||
internal class day1
|
||||
{
|
||||
static public void read()
|
||||
{
|
||||
string file = "./../../../../day1.txt";
|
||||
string text = File.ReadAllText(file);
|
||||
string[] lines = text.Split(
|
||||
new string[] { Environment.NewLine },
|
||||
StringSplitOptions.None);
|
||||
List<int> count = new List<int>();
|
||||
int counter = 0;
|
||||
foreach (string line in lines)
|
||||
{
|
||||
|
||||
if(line.Length != 0)
|
||||
{
|
||||
counter += Convert.ToInt32(line);
|
||||
}
|
||||
else
|
||||
{
|
||||
count.Add(counter);
|
||||
counter = 0;
|
||||
}
|
||||
}
|
||||
count.Sort();
|
||||
foreach(int number in count)
|
||||
{
|
||||
// Console.WriteLine($"{number}");
|
||||
}
|
||||
|
||||
counter = 0;
|
||||
count.Reverse();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
counter += count[i];
|
||||
}
|
||||
|
||||
Console.WriteLine(counter);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
181
Kalender/day2.cs
Normal file
181
Kalender/day2.cs
Normal file
|
@ -0,0 +1,181 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Kalender
|
||||
{
|
||||
/*A = Stein, B = Papier, C = Schere
|
||||
X = Stein, Y = Papier, Z = Schere
|
||||
Stein = 1, Papier = 2, Schere = 3
|
||||
3 Unentschieden, 6 Sieg*/
|
||||
internal class day2
|
||||
{
|
||||
static int counter = 0;
|
||||
static string[] lines;
|
||||
static public void day_2_einlesen()
|
||||
{
|
||||
string file = "./../../../../day2.txt";
|
||||
string text = File.ReadAllText(file);
|
||||
lines = text.Split(
|
||||
new string[] { Environment.NewLine },
|
||||
StringSplitOptions.None);
|
||||
}
|
||||
|
||||
static public void day2_partOne()
|
||||
{
|
||||
day_2_einlesen();
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string ausgang = "";
|
||||
|
||||
if (line[0] == 'A' && line[2] == 'X')
|
||||
{
|
||||
ausgang = "unentschieden";
|
||||
|
||||
}
|
||||
else if (line[0] == 'A' && line[2] == 'Y')
|
||||
{
|
||||
ausgang = "gewonnen";
|
||||
}
|
||||
else if (line[0] == 'A' && line[2] == 'Z')
|
||||
{
|
||||
ausgang = "verloren";
|
||||
}
|
||||
else if (line[0] == 'B' && line[2] == 'X')
|
||||
{
|
||||
ausgang = "verloren";
|
||||
}
|
||||
else if (line[0] == 'B' && line[2] == 'Y')
|
||||
{
|
||||
ausgang = "unentschieden";
|
||||
}
|
||||
else if (line[0] == 'B' && line[2] == 'Z')
|
||||
{
|
||||
ausgang = "gewonnen";
|
||||
}
|
||||
else if (line[0] == 'C' && line[2] == 'X')
|
||||
{
|
||||
ausgang = "gewonnen";
|
||||
}
|
||||
else if (line[0] == 'C' && line[2] == 'Y')
|
||||
{
|
||||
ausgang = "verloren";
|
||||
}
|
||||
else if (line[0] == 'C' && line[2] == 'Z')
|
||||
{
|
||||
ausgang = "unentschieden";
|
||||
}
|
||||
|
||||
counter_(ausgang, line[2]);
|
||||
}
|
||||
Console.WriteLine($"Endergebnis: {counter}");
|
||||
}
|
||||
static private void counter_(string ausgang, char buchstabe)
|
||||
{
|
||||
switch (ausgang)
|
||||
{
|
||||
case "gewonnen":
|
||||
counter += 6;
|
||||
break;
|
||||
case "verloren":
|
||||
counter += 0;
|
||||
break;
|
||||
case "unentschieden":
|
||||
counter += 3;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (buchstabe)
|
||||
{
|
||||
case 'X':
|
||||
counter += 1;
|
||||
break;
|
||||
case 'Y':
|
||||
counter += 2;
|
||||
break;
|
||||
case 'Z':
|
||||
counter += 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
static public void day2_partTwo()
|
||||
{
|
||||
day_2_einlesen();
|
||||
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string ausgang = "";
|
||||
if (line[0] == 'A' && line[2] == 'X')
|
||||
{
|
||||
ausgang = "schere";
|
||||
|
||||
}
|
||||
else if (line[0] == 'A' && line[2] == 'Y')
|
||||
{
|
||||
ausgang = "stein";
|
||||
}
|
||||
else if (line[0] == 'A' && line[2] == 'Z')
|
||||
{
|
||||
ausgang = "papier";
|
||||
}
|
||||
else if (line[0] == 'B' && line[2] == 'X')
|
||||
{
|
||||
ausgang = "stein";
|
||||
}
|
||||
else if (line[0] == 'B' && line[2] == 'Y')
|
||||
{
|
||||
ausgang = "papier";
|
||||
}
|
||||
else if (line[0] == 'B' && line[2] == 'Z')
|
||||
{
|
||||
ausgang = "schere";
|
||||
}
|
||||
else if (line[0] == 'C' && line[2] == 'X')
|
||||
{
|
||||
ausgang = "papier";
|
||||
}
|
||||
else if (line[0] == 'C' && line[2] == 'Y')
|
||||
{
|
||||
ausgang = "schere";
|
||||
}
|
||||
else if (line[0] == 'C' && line[2] == 'Z')
|
||||
{
|
||||
ausgang = "stein";
|
||||
}
|
||||
counter_part_two(ausgang, line[2]);
|
||||
}
|
||||
Console.WriteLine($"Endergebnis: {counter}");
|
||||
}
|
||||
static private void counter_part_two(string ausgang, char buchstabe)
|
||||
{
|
||||
switch (ausgang)
|
||||
{
|
||||
case "stein":
|
||||
counter += 1;
|
||||
break;
|
||||
case "papier":
|
||||
counter += 2;
|
||||
break;
|
||||
case "schere":
|
||||
counter += 3;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (buchstabe)
|
||||
{
|
||||
case 'X':
|
||||
counter += 0;
|
||||
break;
|
||||
case 'Y':
|
||||
counter += 3;
|
||||
break;
|
||||
case 'Z':
|
||||
counter += 6;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
90
Kalender/day3.cs
Normal file
90
Kalender/day3.cs
Normal file
|
@ -0,0 +1,90 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Kalender
|
||||
{
|
||||
internal class day3
|
||||
{
|
||||
static string file = "../../../../day3.txt";
|
||||
static string letters = "0abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
static string[] lines = File.ReadAllLines(file);
|
||||
static List<string> bag1 = new List<string>();
|
||||
static List<string> bag2 = new List<string>();
|
||||
static int sum = 0;
|
||||
|
||||
public static void day3_part1()
|
||||
{
|
||||
Console.WriteLine(letters.Count());
|
||||
|
||||
|
||||
foreach (string line in lines)
|
||||
{
|
||||
bag1.Add(line.Substring(0, (line.Length / 2)));
|
||||
bag2.Add(line.Substring(line.Length / 2));
|
||||
}
|
||||
|
||||
for(int i = 0; i < bag1.Count; i++)
|
||||
{
|
||||
foreach(char c in bag1[i])
|
||||
{
|
||||
|
||||
if (bag2[i].Contains(c))
|
||||
{
|
||||
for(int j = 0; j < letters.Count(); j++)
|
||||
{
|
||||
if(letters[j] == c)
|
||||
{
|
||||
sum += j;
|
||||
}
|
||||
}
|
||||
Console.WriteLine(c);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Console.WriteLine(sum);
|
||||
}
|
||||
public static void day3_part2()
|
||||
{
|
||||
int counter = 0;
|
||||
int start = 0;
|
||||
char bla = ' ';
|
||||
|
||||
while (counter < lines.Count())
|
||||
{
|
||||
|
||||
foreach(char c in lines[start])
|
||||
{
|
||||
if (lines[start].Contains(c) && lines[start+1].Contains(c) && lines[start + 2].Contains(c))
|
||||
{
|
||||
bla = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < letters.Count(); j++)
|
||||
{
|
||||
if (letters[j] == bla)
|
||||
{
|
||||
sum += j;
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine(sum);
|
||||
start += 3;
|
||||
counter +=3;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
138
Kalender/day5.cs
Normal file
138
Kalender/day5.cs
Normal file
|
@ -0,0 +1,138 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Kalender
|
||||
{
|
||||
internal class day5
|
||||
{
|
||||
static List<List<char>> lists = new List<List<char>>();
|
||||
|
||||
// Create Base lists in "lists"
|
||||
public static void createBaseList()
|
||||
{
|
||||
string file = "../../../../day5_base.txt";
|
||||
string[] lines = File.ReadAllLines(file);
|
||||
|
||||
// 9 Columns in file day5_base
|
||||
int column = 9;
|
||||
|
||||
for (int i = 0; i < column; i++)
|
||||
{
|
||||
lists.Add(new List<char>());
|
||||
}
|
||||
|
||||
// If on this index a char, @ it to a specific list
|
||||
foreach (string _line in lines)
|
||||
{
|
||||
if (_line[1] != ' ')
|
||||
{
|
||||
lists[0].Add(_line[1]);
|
||||
|
||||
}
|
||||
if (_line[5] != ' ')
|
||||
{
|
||||
lists[1].Add(_line[5]);
|
||||
|
||||
}
|
||||
if (_line[9] != ' ')
|
||||
{
|
||||
lists[2].Add(_line[9]);
|
||||
|
||||
}
|
||||
if (_line[13] != ' ')
|
||||
{
|
||||
lists[3].Add(_line[13]);
|
||||
|
||||
}
|
||||
if (_line[17] != ' ')
|
||||
{
|
||||
lists[4].Add(_line[17]);
|
||||
|
||||
}
|
||||
if (_line[21] != ' ')
|
||||
{
|
||||
lists[5].Add(_line[21]);
|
||||
|
||||
}
|
||||
if (_line[25] != ' ')
|
||||
{
|
||||
lists[6].Add(_line[25]);
|
||||
|
||||
}
|
||||
if (_line[29] != ' ')
|
||||
{
|
||||
lists[7].Add(_line[29]);
|
||||
|
||||
}
|
||||
if (_line[33] != ' ')
|
||||
{
|
||||
lists[8].Add(_line[33]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static public void getMoveLine()
|
||||
{
|
||||
createBaseList();
|
||||
string file = "../../../../day5.txt";
|
||||
string[] lines = File.ReadAllLines(file);
|
||||
|
||||
|
||||
foreach(string line in lines)
|
||||
{
|
||||
|
||||
|
||||
// Mover
|
||||
List<int> splitTheLineList = new List<int>();
|
||||
splitTheLineList = splitTheLine(line);
|
||||
|
||||
int moveFrom = splitTheLineList[1] -1;
|
||||
int moveAll = splitTheLineList[0];
|
||||
int moveTo = splitTheLineList[2] -1;
|
||||
|
||||
|
||||
for(int i = 0; i < moveAll; i++)
|
||||
{
|
||||
char x = lists[moveFrom].ElementAt(0);
|
||||
lists[moveFrom].RemoveAt(0);
|
||||
lists[moveTo].Reverse();
|
||||
lists[moveTo].Add(x);
|
||||
lists[moveTo].Reverse();
|
||||
}
|
||||
}
|
||||
foreach (List<char> _charList in lists)
|
||||
{
|
||||
|
||||
Console.WriteLine(_charList[0]);
|
||||
}
|
||||
}
|
||||
|
||||
// Removes the Words, and store the needed Numbers
|
||||
static List<int> splitTheLine(string line)
|
||||
{
|
||||
List<int> list = new List<int>();
|
||||
line = line.Replace("move ", "");
|
||||
line = line.Replace("from ", "");
|
||||
line = line.Replace("to ", "");
|
||||
|
||||
var a =line.Split(' ');
|
||||
foreach (string i in a)
|
||||
{
|
||||
list.Add(Convert.ToInt32(i));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user