chore(*): Move all C# solutions into a C# folder to make it clearer which languages are used

This commit is contained in:
Josh Creek
2024-12-01 11:19:35 +00:00
parent 1a4d7a2d95
commit 9d53354d14
71 changed files with 7 additions and 0 deletions
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
</PropertyGroup>
<ItemGroup>
<Compile Remove="DayX.cs"/>
</ItemGroup>
<ItemGroup>
<Content Include="DayX.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
+46
View File
@@ -0,0 +1,46 @@
namespace AOC.Tests.YX;
[TestFixture]
[Parallelizable(ParallelScope.All)]
public class DayX
{
[SetUp]
public void Setup()
{
realData = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, "YX", "Data",
$"{GetThisClassName()}.dat"));
}
protected string GetThisClassName() { return GetType().Name; }
private string[] realData;
[TestCase("blah", 0)]
[TestCase(null, 232)] // The actual answer
public void Part1(string? input, int? expected)
{
string[] lines = input != null ? new[] { input } : realData;
// string[] lines = input != null ? input.Split("\n") : realData;
//if (expected != null)
//{
// Assert.That(result, Is.EqualTo(expected.Value));
//}
//Console.WriteLine($"Part 1: {result}");
}
[TestCase("blah", 1)]
[TestCase(null, 1783)] // The actual answer
public void Part2(string? input, int? expected)
{
//string[] lines = input != null ? new[] { input } : realData;
// string[] lines = input != null ? input.Split("\n") : realData;
//if (expected != null)
//{
// Assert.That(result, Is.EqualTo(expected.Value));
//}
//Console.WriteLine($"Part 2: {result}");
}
}
+49
View File
@@ -0,0 +1,49 @@
using System.Collections.Generic;
using System;
using System.IO;
using System.Text;
Console.Write("Year: ");
var year = Console.ReadLine();
Console.Write("Day: ");
var day = Console.ReadLine().PadLeft(2, '0'); ;
var currentLocation = System.Reflection.Assembly.GetExecutingAssembly().Location;
int ix = currentLocation.IndexOf("DayCreator");
var newPathBase = currentLocation.Substring(0, ix - 1);
var newDayCreatorBase = currentLocation.Substring(0, ix + "DayCreator".Length);
string yearPath = Path.GetFullPath(Path.Combine(newPathBase, "AOC.Tests", $"Y{year}"));
string dataPath = Path.GetFullPath(Path.Combine(yearPath, "Data", $"Day{day}.dat"));
string tasksPath = Path.GetFullPath(Path.Combine(yearPath, "Tasks", $"Day{day}.txt"));
// Check and create missing directories
if (!Directory.Exists(yearPath))
{
Directory.CreateDirectory(yearPath);
}
if (!Directory.Exists(Path.Combine(yearPath, "Data")))
{
Directory.CreateDirectory(Path.Combine(yearPath, "Data"));
}
if (!Directory.Exists(Path.Combine(yearPath, "Tasks")))
{
Directory.CreateDirectory(Path.Combine(yearPath, "Tasks"));
}
// Create data file
using (FileStream fs = File.Create(dataPath));
// Create task file
using (FileStream fs = File.Create(tasksPath));
// Create code file
var dayXPath = Path.GetFullPath(Path.Combine(newDayCreatorBase, "DayX.cs"));
string text = File.ReadAllText(dayXPath);
text = text.Replace("YX", $"Y{year}");
text = text.Replace("DayX", $"Day{day}");
var writePath = Path.GetFullPath(Path.Combine(yearPath, $"Day{day}.cs"));
File.WriteAllText(writePath, text);