using System.Collections.Generic;
namespace KataTrain190319
static int Factorial(int i)
throw new Exception("Welcome to the rice fields motherfucker");
for (int j = 2; j <= i; j++)
static void Main(string[] args)
List<int> ls = new List<int>{ 50 };
List<int> lsIndexes = new List<int>();
List<int> lsPermutationSums = new List<int>();
for (int i = 0; i < k; i++)
lsPermutationSums.Add(0);
lsPermutationSums[0] += ls[i];
long counter = Factorial(n) / (Factorial(n - k)*Factorial(k));
for(int i = k - 1; i >= 0; i--)
if(i == k - 1 && lsIndexes[i] != n - k + i)
else if(shift == true && lsIndexes[i] != n - k + i && lsIndexes[i + 1] == n - k + i + 1)
for(int j = i + 1; j < k; j++)
lsIndexes[j] = lsIndexes[j - 1] + 1;
else if (lsIndexes[i] == n - k + i)
lsPermutationSums.Add(l);
foreach (var j in lsIndexes)
lsPermutationSums[index] += ls[j];
lsPermutationSums.Sort();
for (int i = lsPermutationSums.Count - 1; i >= 0; i--)
if (lsPermutationSums[i] <= t)
res = lsPermutationSums[i];