diff --git a/Gold Splitter.csproj b/Gold Splitter.csproj
new file mode 100644
index 0000000..cfa229a
--- /dev/null
+++ b/Gold Splitter.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net6.0
+ GoldSplitter
+ disable
+ enable
+
+
+
diff --git a/Gold Splitter.sln b/Gold Splitter.sln
new file mode 100644
index 0000000..a5e1e10
--- /dev/null
+++ b/Gold Splitter.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.3.32804.467
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gold Splitter", "Gold Splitter.csproj", "{407290BD-8743-46B1-902B-45AB61C55661}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {407290BD-8743-46B1-902B-45AB61C55661}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {407290BD-8743-46B1-902B-45AB61C55661}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {407290BD-8743-46B1-902B-45AB61C55661}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {407290BD-8743-46B1-902B-45AB61C55661}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {DDD05195-4059-4D20-B784-22830C1B8BC5}
+ EndGlobalSection
+EndGlobal
diff --git a/Program.cs b/Program.cs
new file mode 100644
index 0000000..1b1906a
--- /dev/null
+++ b/Program.cs
@@ -0,0 +1,71 @@
+using System;
+
+namespace GoldSplitter;
+using System;
+
+internal static class Program
+{
+ public static NamedAction[] actions =
+ {
+ new ("Split", package =>
+ {
+ Console.WriteLine("Split with how many?");
+ int people = int.Parse(Console.ReadLine() ?? "0");
+ Console.WriteLine(package.Split(people));
+ }),
+ new ("To All Copper", package =>
+ {
+ Console.WriteLine(package.ToAllCopper().Copper);
+ })
+ };
+ static void Main()
+ {
+ GoldPackage gold = GoldPackage.HumanInput();
+ Console.WriteLine("Choose an action:");
+ for (int i = 0; i < actions.Length; i++)
+ Console.WriteLine($"{i + 1}. {actions[i].Name}");
+ actions[int.Parse(Console.ReadLine() ?? "0") - 1].Action.Invoke(gold);
+ Console.ReadLine();
+ }
+}
+public record NamedAction(string Name, Action Action);
+public record GoldPackage(int Platinum, int Gold, int Silver, int Copper)
+{
+ public const int copperRepresentative = 1, silverRepresentative = 10, goldRepresentative = 100, platinumRepresentative = 1000;
+ public static explicit operator int(GoldPackage package)
+ => package.ToAllCopper().Copper;
+ public static GoldPackage HumanInput()
+ {
+ Console.Write("Platinum: ");
+ int plat = int.Parse(Console.ReadLine() ?? "0");
+ Console.Write("Gold: ");
+ int gold = int.Parse(Console.ReadLine() ?? "0");
+ Console.Write("Silver: ");
+ int silver = int.Parse(Console.ReadLine() ?? "0");
+ Console.Write("Copper: ");
+ int copper = int.Parse(Console.ReadLine() ?? "0");
+ return new GoldPackage(plat, gold, silver, copper);
+ }
+
+ public GoldPackage Split(int people)
+ {
+ int copper = ToAllCopper().Copper;
+ copper /= people;
+ return new GoldPackage(0, 0, 0, copper).DisperseToAppropriateCoinValues();
+ }
+ public GoldPackage ToAllCopper() => new(0, 0, 0, (Copper * copperRepresentative)
+ + (Silver * silverRepresentative) + (Gold * goldRepresentative)
+ + (Platinum * platinumRepresentative));
+ public GoldPackage DisperseToAppropriateCoinValues()
+ {
+ int copperTotal = ToAllCopper().Copper;
+ int platinumOut = copperTotal / platinumRepresentative;
+ copperTotal -= platinumOut * platinumRepresentative;
+ int goldOut = copperTotal / goldRepresentative;
+ copperTotal -= goldOut * goldRepresentative;
+ int silverOut = copperTotal / silverRepresentative;
+ copperTotal -= silverOut * silverRepresentative;
+ int copperOut = copperTotal;
+ return new GoldPackage(platinumOut, goldOut, silverOut, copperOut);
+ }
+}
\ No newline at end of file