Skip to content

Instantly share code, notes, and snippets.

View m-khooryani's full-sized avatar

Mojtaba Khooryani m-khooryani

  • Polestar
  • Gothenburg, Sweden
View GitHub Profile
@m-khooryani
m-khooryani / Program.cs
Last active July 1, 2020 15:05
Partition Problem (DP)
class Program
{
static void Main(string[] args)
{
int[] a = new int[] { 15, 5, 20, 10, 35, 15, 10 };
Console.WriteLine(Partition(a, a.Sum() / 2)); // true
}
private static bool Partition(int[] a, int S)
@m-khooryani
m-khooryani / Program.cs
Created July 2, 2020 09:30
Count Paths in n*m Matrix (DP)
static void Main(string[] args)
{
int n = 5, m = 5;
Console.WriteLine(CountPaths(n, m)); // 70
}
static int CountPaths(int n, int m)
{
int[,] dp = new int[n, m];
dp[n - 1, m - 1] = 1;
@m-khooryani
m-khooryani / Program.cs
Created March 9, 2021 21:48
without middleware function app
[FunctionName(nameof(SomeCommandFunction))]
public static async Task<Guid> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post")]
HttpRequestData req, FunctionExecutionContext executionContext,
ILogger logger,
IUnitOfWork unitOfWork)
{
logger.LogInformation("Function started");
// some Logic (skipped for simplicity)
var addedId = Guid.NewGuid();