Smab.Helpers
1.10.13
dotnet add package Smab.Helpers --version 1.10.13
NuGet\Install-Package Smab.Helpers -Version 1.10.13
<PackageReference Include="Smab.Helpers" Version="1.10.13" />
<PackageVersion Include="Smab.Helpers" Version="1.10.13" />
<PackageReference Include="Smab.Helpers" />
paket add Smab.Helpers --version 1.10.13
#r "nuget: Smab.Helpers, 1.10.13"
#:package Smab.Helpers@1.10.13
#addin nuget:?package=Smab.Helpers&version=1.10.13
#tool nuget:?package=Smab.Helpers&version=1.10.13
Smab.Helpers
A comprehensive C# helper library targeted at Advent of Code providing utilities for grid/matrix operations, parsing, mathematics, algorithms, JSON serialization, and more. Designed for .NET 10.0 with modern C# features.
Installation
Install via NuGet Package Manager:
dotnet add package Smab.Helpers
Or via Package Manager Console:
Install-Package Smab.Helpers
Features
Smab.Helpers provides a rich set of extension methods and utilities organized into the following categories:
📐 Grid & Spatial Helpers
- Point & Point3d: Robust 2D and 3D point structures with operator overloading
- Direction & HexDirection: Enums for cardinal, intercardinal, and hexagonal directions
- Cell & Cube: Grid cell representations
- Grid Operations: Transpose, rotate, flip, fill, adjacency detection
- Pathfinding: Dijkstra's algorithm implementation
- Coordinate Systems: Hexagonal coordinate support
🔢 Parsing Helpers
- Parse strings to numbers, points, cells, enums
- Binary/hex/octal conversions
- Split and trim utilities
- Digit extraction
- Regex-based parsing helpers
🧮 Mathematics Helpers
- Statistical operations: Mean, median, mode, min/max
- Number range operations and overlap detection
- Linear equation solver
- LCM (Least Common Multiple) calculation
- Base conversions
- Number validation and range checking
🔄 Algorithmic Helpers
- Dijkstra's shortest path algorithm
- Permutations and combinations
- Binary search (binary chop)
- Manhattan distance calculation
- Sequence helpers
🗂️ LINQ Extensions
ForEach: Execute actions on collectionsIsIn: Check membershipNotWhere: Inverse filteringDoesNotContain: Inverse contains check
📅 DateTime Extensions
- Additional date/time manipulation utilities
📦 JSON Helpers
JsonDateOnlyConverter: Serialize/deserializeDateOnlyinyyyy-MM-ddformatJsonTimeOnlyConverter: Serialize/deserializeTimeOnlyinHH:mm:ssformatJsonUnixDateConverter: Unix timestamp conversion
🎨 UTF-16 Character Collections
Extensive Unicode character sets for console/terminal applications:
- Box drawing characters
- Block elements
- Geometric shapes
- Mathematical symbols (A & B sets)
- Arrows (standard and supplemental A & B)
- Braille patterns
- Dingbats
- Musical symbols
- Hebrew characters
- And more!
🌐 HTML Helpers
HasClass: Check for CSS class presence in HTML elements
🎯 Advent of Code Helpers
- OCR helpers for recognizing ASCII art letters
Usage Examples
Grid & Point Operations
using Smab.Helpers;
// Create and manipulate points
var p1 = new Point(5, 10);
var p2 = new Point(3, 4);
var sum = p1 + p2; // (8, 14)
var diff = p1 - p2; // (2, 6)
var scaled = p1 * 2; // (10, 20)
// Predefined points
var origin = Point.Zero; // (0, 0)
var unit = Point.One; // (1, 1)
var unitX = Point.UnitX; // (1, 0)
// 3D points
var p3d = new Point3d(1, 2, 3);
// Directions
var direction = Direction.North | Direction.East; // NorthEast
var hexDir = HexDirection.NE;
Grid/Array Operations
// Create a 2D array
int[,] grid = new int[5, 5];
// Fill with a value
grid.Fill(0);
// Get adjacent cells (4-directional)
var adjacent = grid.GetAdjacentCells(new Point(2, 2));
// Get adjacent cells (8-directional including diagonals)
var adjacentWithDiagonals = grid.GetAdjacentCells(new Point(2, 2), includeDiagonals: true);
// Transpose a grid
var transposed = grid.Transpose();
// Rotate 90 degrees
var rotated = grid.RotateRight();
// Flip horizontally or vertically
var flipped = grid.FlipHorizontally();
// Convert to string array
string[] rows = grid.AsStrings();
Parsing Helpers
using Smab.Helpers;
// Parse numbers from delimited string
string input = "1, 2, 3, 4, 5";
IEnumerable<int> numbers = input.AsNumbers<int>();
// or
var ints = input.AsInts();
var longs = input.AsLongs();
// Parse to specific type
int value = "42".As<int>();
double pi = "3.14159".As<double>();
// Parse enum
var myEnum = "Value1".AsEnum<MyEnum>();
// Parse points
var point = "(5, 10)".As<Point>();
// Extract digits from string
string text = "abc123def456";
var digits = text.AsDigits(); // "123456"
// Split and trim
string csv = " a , b , c ";
var parts = csv.TrimmedSplit(','); // ["a", "b", "c"]
// Binary conversions
string binary = "FF".AsBinaryFromHex(); // "11111111"
string fromOctal = "17".AsBinaryFromOctal(); // "1111"
int fromBinary = "1010".FromBinaryAs<int>(); // 10
Mathematical Operations
using Smab.Helpers;
// Statistical operations
var numbers = new[] { 1, 2, 3, 4, 5 };
var mean = numbers.Mean(); // 3.0
var median = numbers.Median(); // 3
var modes = numbers.Modes(); // Most frequent values
// Min/Max
var (min, max) = numbers.MinMax();
// Check if number is in range
bool inRange = 5.IsInRange(1, 10); // true
bool inRangeEx = 5.IsInRange(1, 5, true); // false (exclusive end)
// Range overlap
var (overlapStart, overlapEnd) = (1, 10).GetOverlap((5, 15)); // (5, 10)
// Solve linear equations: ax + by = c
bool solved = MathsHelpers.TrySolveLinearEquations(
ax: 2, bx: 3, cx: 12,
ay: 4, by: 1, cy: 11,
out var result);
// result.A and result.B contain the solution
// LCM (Least Common Multiple)
long lcm = MathsHelpers.LCM(12, 18); // 36
// Base conversions
string binary = 42.ToBinaryAsString(); // "101010"
string hex = 255.ToBaseAsString(16); // "ff"
Algorithmic Helpers
using Smab.Helpers;
// Dijkstra's shortest path
int[,] grid = LoadGrid();
var costs = AlgorithmicHelpers.DijkstrasBasedOnCellValue(
grid,
start: new Point(0, 0),
end: new Point(9, 9)
);
// Manhattan distance
int distance = AlgorithmicHelpers.ManhattanDistance(
new Point(0, 0),
new Point(3, 4)
); // 7
// Permutations
var items = new[] { 1, 2, 3 };
var permutations = items.Permute();
// Combinations
var combinations = items.Combinations(2);
// Binary search
var sortedList = new List<int> { 1, 3, 5, 7, 9 };
int index = sortedList.BinaryChop(5); // 2
LINQ Extensions
using Smab.Helpers;
// ForEach extension
var numbers = new[] { 1, 2, 3, 4, 5 };
numbers.ForEach(n => Console.WriteLine(n));
// IsIn - alternative to Contains
int value = 3;
bool exists = value.IsIn(1, 2, 3, 4, 5); // true
// NotWhere - inverse of Where
var filtered = numbers.NotWhere(n => n % 2 == 0); // [1, 3, 5]
// DoesNotContain
var list = new List<int> { 1, 2, 3 };
bool missing = list.DoesNotContain(4); // true
JSON Converters
using System.Text.Json;
using Smab.Helpers;
var options = new JsonSerializerOptions {
Converters = {
new JsonDateOnlyConverter(),
new JsonTimeOnlyConverter(),
new JsonUnixDateConverter()
}
};
var obj = new MyClass {
Date = new DateOnly(2024, 1, 15),
Time = new TimeOnly(14, 30, 0)
};
string json = JsonSerializer.Serialize(obj, options);
// {"Date":"2024-01-15","Time":"14:30:00"}
UTF-16 Characters
using Smab.Helpers;
// Box drawing
Console.WriteLine(Utf16Chars.BOX_DRAWINGS_LIGHT_HORIZONTAL);
Console.WriteLine(Utf16Chars.BOX_DRAWINGS_LIGHT_VERTICAL);
// Arrows
Console.WriteLine(Utf16Chars.LEFTWARDS_ARROW);
Console.WriteLine(Utf16Chars.UPWARDS_ARROW);
// Mathematical symbols
Console.WriteLine(Utf16Chars.SQUARE_ROOT);
Console.WriteLine(Utf16Chars.INFINITY);
// Musical symbols
Console.WriteLine(Utf16Strings.Musical.STAFF_5_LINES);
// Block elements
Console.WriteLine(Utf16Chars.FULL_BLOCK);
Console.WriteLine(Utf16Chars.LIGHT_SHADE);
Console Helpers
using Smab.Helpers;
// Check for non-whitespace content
string input = " ";
bool hasContent = input.HasNonWhiteSpaceContent(); // false
// Non-empty string check
string? text = GetSomeText();
if (text.NonEmptyString() is string validText) {
Console.WriteLine(validText);
}
API Documentation
The library extensively uses XML documentation comments. Enable IntelliSense in your IDE to get detailed descriptions, parameter information, and usage examples for all methods.
Target Framework
- .NET 10.0
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests on GitHub.
License
This project is licensed under the MIT License.
Author
Simon Brookes (@smabuk)
Repository
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.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 |
|---|---|---|
| 1.10.13 | 261 | 12/16/2025 |
| 1.10.12 | 113 | 12/12/2025 |
| 1.10.10 | 113 | 12/12/2025 |
| 1.10.9 | 444 | 12/9/2025 |
| 1.10.7 | 427 | 12/8/2025 |
| 1.10.5 | 414 | 12/8/2025 |
| 1.10.4 | 330 | 12/8/2025 |
| 1.10.2 | 298 | 12/7/2025 |
| 1.10.0 | 286 | 12/7/2025 |
| 1.9.19 | 216 | 12/7/2025 |
| 1.9.18 | 201 | 12/7/2025 |
| 1.9.13 | 204 | 12/7/2025 |
| 1.9.12 | 125 | 12/6/2025 |
| 1.9.11 | 169 | 12/5/2025 |
| 1.9.10 | 165 | 12/5/2025 |
| 1.9.9 | 171 | 12/5/2025 |
| 1.9.8 | 162 | 12/5/2025 |
| 1.9.7 | 179 | 12/5/2025 |
| 1.9.6 | 194 | 12/4/2025 |
| 1.9.5 | 190 | 12/4/2025 |
| 1.9.4 | 654 | 12/3/2025 |
| 1.9.3 | 666 | 12/2/2025 |
| 1.9.2 | 684 | 12/1/2025 |
| 1.9.1 | 270 | 11/21/2025 |
| 1.9.0 | 282 | 11/11/2025 |
| 1.8.2 | 192 | 10/20/2025 |
| 1.8.1 | 175 | 10/20/2025 |
| 1.7.31 | 313 | 4/17/2025 |
| 1.7.30 | 256 | 4/17/2025 |
| 1.7.29 | 201 | 12/18/2024 |
| 1.7.27 | 216 | 12/14/2024 |
| 1.7.26 | 200 | 12/13/2024 |
| 1.7.25 | 191 | 12/12/2024 |
| 1.7.24 | 188 | 12/12/2024 |
| 1.7.23 | 187 | 12/12/2024 |
| 1.7.21 | 204 | 12/12/2024 |
| 1.7.20 | 179 | 12/11/2024 |
| 1.7.19 | 219 | 12/10/2024 |
| 1.7.17 | 178 | 12/10/2024 |
| 1.7.16 | 187 | 12/8/2024 |
| 1.7.15 | 196 | 12/8/2024 |
| 1.7.13 | 197 | 12/7/2024 |
| 1.7.12 | 245 | 12/4/2024 |
| 1.7.9 | 234 | 12/1/2024 |
| 1.7.8 | 178 | 12/1/2024 |
| 1.7.7 | 185 | 12/1/2024 |
| 1.7.6 | 188 | 11/28/2024 |
| 1.7.4 | 177 | 11/24/2024 |
| 1.7.2 | 185 | 11/24/2024 |
| 1.7.1 | 173 | 11/23/2024 |
| 1.7.0 | 182 | 11/23/2024 |
| 1.6.9 | 197 | 11/13/2024 |
| 1.6.8 | 193 | 11/4/2024 |
| 1.6.7 | 197 | 11/2/2024 |
| 1.6.6 | 200 | 11/2/2024 |
| 1.6.4 | 179 | 11/2/2024 |
| 1.6.3 | 195 | 11/2/2024 |
| 1.6.2 | 220 | 11/2/2024 |
| 1.6.1 | 201 | 10/29/2024 |
| 1.6.0 | 216 | 10/27/2024 |
| 1.5.13 | 213 | 5/20/2024 |
| 1.5.12 | 192 | 5/19/2024 |
| 1.5.11 | 225 | 2/15/2024 |
| 1.5.10 | 214 | 2/14/2024 |
| 1.5.9 | 211 | 1/18/2024 |
| 1.5.7 | 254 | 1/1/2024 |
| 1.5.6 | 215 | 12/25/2023 |
| 1.5.5 | 207 | 12/23/2023 |
| 1.5.4 | 218 | 12/23/2023 |
| 1.5.3 | 202 | 12/22/2023 |
| 1.5.2 | 214 | 12/22/2023 |
| 1.5.1 | 221 | 12/20/2023 |
| 1.5.0 | 230 | 12/18/2023 |
| 1.4.14 | 199 | 12/17/2023 |
| 1.4.13 | 211 | 12/17/2023 |
| 1.4.12 | 205 | 12/17/2023 |
| 1.4.11 | 216 | 12/17/2023 |
| 1.4.10 | 241 | 12/16/2023 |
| 1.4.9 | 208 | 12/15/2023 |
| 1.4.8 | 220 | 12/15/2023 |
| 1.4.7 | 221 | 12/14/2023 |
| 1.4.6 | 235 | 12/13/2023 |
| 1.4.4 | 230 | 12/13/2023 |
| 1.4.3 | 218 | 12/13/2023 |
| 1.4.2 | 217 | 12/11/2023 |
| 1.4.1 | 230 | 12/10/2023 |
| 1.4.0 | 238 | 12/8/2023 |
| 1.3.14 | 188 | 12/8/2023 |
| 1.3.13 | 225 | 12/8/2023 |
| 1.3.12 | 198 | 12/8/2023 |
| 1.3.11 | 210 | 12/6/2023 |
| 1.3.10 | 193 | 12/6/2023 |
| 1.3.9 | 171 | 12/6/2023 |
| 1.3.8 | 173 | 12/6/2023 |
| 1.3.7 | 171 | 12/5/2023 |
| 1.3.6 | 185 | 12/5/2023 |
| 1.3.5 | 187 | 12/4/2023 |
| 1.3.4 | 151 | 12/4/2023 |
| 1.3.3 | 165 | 12/6/2023 |
| 1.3.2 | 202 | 12/2/2023 |
| 1.3.1 | 236 | 11/15/2023 |
| 1.3.0 | 165 | 11/15/2023 |
| 1.2.15 | 179 | 11/15/2023 |
| 1.2.14 | 237 | 10/12/2023 |
| 1.2.13 | 449 | 1/19/2023 |
| 1.2.12 | 423 | 12/23/2022 |
| 1.2.11 | 425 | 12/22/2022 |
| 1.2.10 | 444 | 12/18/2022 |
| 1.2.9 | 485 | 12/12/2022 |
| 1.2.8 | 420 | 12/11/2022 |
| 1.2.7 | 393 | 12/10/2022 |
| 1.2.6 | 396 | 12/10/2022 |
| 1.2.5 | 393 | 12/10/2022 |
| 1.2.4 | 404 | 12/9/2022 |
| 1.2.2 | 419 | 12/9/2022 |
| 1.2.1 | 459 | 12/1/2022 |
| 1.2.0 | 463 | 11/20/2022 |
| 1.1.1 | 555 | 5/29/2022 |
| 1.1.0 | 525 | 5/29/2022 |
| 1.0.1 | 573 | 5/22/2022 |
| 1.0.0 | 559 | 5/21/2022 |
.NET 10.0