Leet 4.0.1
dotnet add package Leet --version 4.0.1
NuGet\Install-Package Leet -Version 4.0.1
<PackageReference Include="Leet" Version="4.0.1" />
paket add Leet --version 4.0.1
#r "nuget: Leet, 4.0.1"
// Install Leet as a Cake Addin #addin nuget:?package=Leet&version=4.0.1 // Install Leet as a Cake Tool #tool nuget:?package=Leet&version=4.0.1
Leet
Tackling Coding Challenges as easy as it gets.
👋🏼 Welcome!
Anyone who's ever worked in code editors like the one provided by LeetCode knows that it's quite a challenge in itself. No debugger or IntelliSense support make it completely useless except for auto-testing your solution with necessary inputs. In case of a bug that'll inevitably crop up in your solution, you'll be forced to switch to an actual IDE anyway.
But it's arguably a more convenient option because now you are faced with other issues:
- constructing necessary objects
- defining variables to store results
- validating the results
- feeding the input data...
...especially arrays that are ubiquitous in those challenges, and only their construction alone takes a significant amount of time. And what if they are jagged?.. *sigh*
Leet is designed to make working on solutions in your favorite IDE trivial avoiding all the common inconveniences related to that.
🥗 Recipes
🟢 Let It Help You
using Leet;//⬅️Include the package after it was installed
// Specify the result type of your solution and the type where it's defined.
var solution = new MySolution<Solution, int>();
// Test it.
solution.Test(expected: 0,
100,
"[1, -2, +3, -4, 5]", // Array arguments can be provided as strings.
"{{ 1, 2 }, { 3, 4 }}", // Jagged arrays are also supported.
new int[] { 1, 2, 3 } // Sure you can do that, but why complicate things?
);
// Write your solution inside the class of your choosing.
public class MySolution
{
[Solution]//⬅️Label your solution method
public int ReturnResult(
//↖️Result type
int param,
int[] canBeProvidedAsString,
int[][] evenJaggedArrays,
int[] andAsRegularArrayToo
)
{
int result = default;
return result;//⬅️Result is returned
}
}
🔤 Store Result in Parameter
var solution = new Solution<MySolution, double[]>();
public class MySolution
{
//↙️No attribute here
//↙️Return type is void
public void StoreResultInParameter(
//↙️Label the parameter that'll store the result.
[Result]double[] resultParameter
) //↖️Result type
{
// Modify the array in-place.
Array.Sort(resultParameter);
// resultParameter will reflect the changes. No need to return any value.
}
}
📡 Interpret Them Your Way
var solution = new Solution<Solution, double[]>();
// You can provide a custom interpreter for the elements inside a string array.
Func<string, double> doubleInterpreter = double.Parse; // (default is int.Parse)
// Pass it as the function parameter...↘️
solution.Test("[1.5, 2.3]", interpreter: doubleInterpreter, "[[1.0], [2.0]]");
// ...or use it separately.
// Just include `using CCEasy.Services.StringInterpreter;` at the top of the file.
// Using instance interface.
string doubleArrayString = "[.1, .2, .3]";
var interpreter = new CollectionInStringInterpreter<double>(doubleArrayString, double.Parse);
double[] array = interpreter.ToArray();
var enumerable = interpreter.ToEnumerable();
string jaggedArrayString = "[ [1], [2], [3] ]";
var jaggedInterpreter = new CollectionInStringInterpreter<double>(doubleArrayString, double.Parse);
var jaggedArray = jaggedInterpreter.ToJaggedArray();
// Using static interface.
object? doubleArrayHolder = doubleArrayString;
object? jaggedArrayHolder = jaggedArrayString;
CollectionInStringInterpreter<double>.TryInterpret(ref doubleArrayHolder, double.Parse);
CollectionInStringInterpreter<int>.TryInterpret(ref jaggedArrayHolder, int.Parse);
⚙️ Features
- Intuitive interface
- Arrays can be handled as strings
- Any types and values are supported
- Documentation is included in the package
- Visualization support for enumerables
- Seamless workflow
- Type-safe
- Friendly exception messages
💡 Suggestions
Feel free to leave your proposals in Issues section. Any feedback is highly appreciated.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.0.1 | 462 | 5/14/2022 |
Fix bug with solution container instance being shared across test runs.