Skip to content

Commit 8874360

Browse files
committed
Clean up combinatorics
1 parent 9fe7cf6 commit 8874360

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/Advanced.Algorithms/Combinatorics/Combination.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static List<List<T>> Find<T>(List<T> n, int r, bool withRepetition = fals
1717
return result;
1818
}
1919

20-
private static void recurse<T>(List<T> input, int r, bool withRepetition,
20+
private static void recurse<T>(List<T> n, int r, bool withRepetition,
2121
int k, List<T> prefix, HashSet<int> prefixIndices,
2222
List<List<T>> result)
2323
{
@@ -27,17 +27,17 @@ private static void recurse<T>(List<T> input, int r, bool withRepetition,
2727
return;
2828
}
2929

30-
for (int j = k; j < input.Count; j++)
30+
for (int j = k; j < n.Count; j++)
3131
{
3232
if (prefixIndices.Contains(j) && !withRepetition)
3333
{
3434
continue;
3535
}
3636

37-
prefix.Add(input[j]);
37+
prefix.Add(n[j]);
3838
prefixIndices.Add(j);
3939

40-
recurse(input, r, withRepetition, j, prefix, prefixIndices, result);
40+
recurse(n, r, withRepetition, j, prefix, prefixIndices, result);
4141

4242
prefix.RemoveAt(prefix.Count - 1);
4343
prefixIndices.Remove(j);

src/Advanced.Algorithms/Combinatorics/Permutation.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static List<List<T>> Find<T>(List<T> n, int r, bool withRepetition = fals
1717
return result;
1818
}
1919

20-
private static void recurse<T>(List<T> input, int r, bool withRepetition,
20+
private static void recurse<T>(List<T> n, int r, bool withRepetition,
2121
List<T> prefix, HashSet<int> prefixIndices,
2222
List<List<T>> result)
2323
{
@@ -27,17 +27,17 @@ private static void recurse<T>(List<T> input, int r, bool withRepetition,
2727
return;
2828
}
2929

30-
for (int j = 0; j < input.Count; j++)
30+
for (int j = 0; j < n.Count; j++)
3131
{
3232
if (prefixIndices.Contains(j) && !withRepetition)
3333
{
3434
continue;
3535
}
3636

37-
prefix.Add(input[j]);
37+
prefix.Add(n[j]);
3838
prefixIndices.Add(j);
3939

40-
recurse(input, r, withRepetition, prefix, prefixIndices, result);
40+
recurse(n, r, withRepetition, prefix, prefixIndices, result);
4141

4242
prefix.RemoveAt(prefix.Count - 1);
4343
prefixIndices.Remove(j);

0 commit comments

Comments
 (0)