Skip to content

Commit

Permalink
Completed initial hussy dry run for two-sum.
Browse files Browse the repository at this point in the history
  • Loading branch information
tacosontitan committed Apr 11, 2024
1 parent 3768a80 commit 2b0aee7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 23 additions & 0 deletions samples/Hussy.Net.Playground/Leetcode/Easy/TwoSum/HussyDryRun.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Hussy.Net.Playground.Leetcode.Easy;

/// <summary>
/// Represents a solution and its tests for the leetcode two-sum problem.
/// </summary>
/// <see href="https://leetcode.com/problems/two-sum/description/"/>
public sealed partial class TwoSum
{
/// <summary>
/// A very mundane and direct approach to solving the problem to understand where Hussy may be lacking.
/// </summary>
/// <param name="numbers">The array of numbers to look through.</param>
/// <param name="target">
/// The target number which the two numbers in <paramref name="numbers"/> must add up to.
/// </param>
/// <returns>
/// The two indices of the numbers which add up to the <paramref name="target"/>.
/// </returns>
private static IEnumerable<int>? HussyDryRun(
int[] n,
int t) =>
n.Fe((x, y) => x.I != y.I && x.V + y.V == t,(x, y) => new[] { x.I, y.I });
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public sealed partial class TwoSum
DryRun,
GolfedDryRun,
ComplexityRun,
GolfedComplexityRun
GolfedComplexityRun,
HussyDryRun

Check warning on line 18 in samples/Hussy.Net.Playground/Leetcode/Easy/TwoSum/Tests/Setup.cs

View workflow job for this annotation

GitHub Actions / build

Nullability of reference types in return type of 'IEnumerable<int>? TwoSum.HussyDryRun(int[] n, int t)' doesn't match the target delegate 'TwoSum.TestFunction' (possibly because of nullability attributes).

Check warning on line 18 in samples/Hussy.Net.Playground/Leetcode/Easy/TwoSum/Tests/Setup.cs

View workflow job for this annotation

GitHub Actions / build

Nullability of reference types in return type of 'IEnumerable<int>? TwoSum.HussyDryRun(int[] n, int t)' doesn't match the target delegate 'TwoSum.TestFunction' (possibly because of nullability attributes).
];

/// <summary>
Expand Down

0 comments on commit 2b0aee7

Please sign in to comment.