diff --git a/src/ProjectEuler/Puzzles/Puzzle039.cs b/src/ProjectEuler/Puzzles/Puzzle039.cs index 4630edd9..2f9bb52d 100644 --- a/src/ProjectEuler/Puzzles/Puzzle039.cs +++ b/src/ProjectEuler/Puzzles/Puzzle039.cs @@ -32,9 +32,9 @@ internal static ICollection Solve(int perimeter) for (double b = 1; b < perimeter - a - 1; b++) { double tangent = a / b; - double theta = Math.Atan(tangent); + double θ = Math.Atan(tangent); - double c = a / Math.Sin(theta); + double c = a / Math.Sin(θ); if (Math.Abs(a + b + c - perimeterDouble) < double.Epsilon) { @@ -45,7 +45,7 @@ internal static ICollection Solve(int perimeter) c.ToString(Format, formatProvider), ]; - string solution = $"{{{string.Join(",", sides.Order())}}}"; + string solution = '{' + string.Join(',', sides.Order()) + '}'; solutions.Add(solution); } diff --git a/src/ProjectEuler/Puzzles/Puzzle042.cs b/src/ProjectEuler/Puzzles/Puzzle042.cs index ddf984fc..58fe7474 100644 --- a/src/ProjectEuler/Puzzles/Puzzle042.cs +++ b/src/ProjectEuler/Puzzles/Puzzle042.cs @@ -51,17 +51,16 @@ internal IList ReadWords() using var stream = ReadResource(); using var reader = new StreamReader(stream); - string rawWords = reader.ReadToEnd(); + var text = reader.ReadToEnd().AsSpan(); + var words = new List(); - string[] split = rawWords.Split(','); - - var words = new List(split.Length); - - foreach (string word in split) + foreach (var word in text.Split(',')) { - words.Add(word.Trim('\"')); + words.Add(text[word].Trim('\"').ToString()); } + words.TrimExcess(); + return words; }