Skip to content

Commit 4baca7d

Browse files
committed
rn
1 parent d7f5b46 commit 4baca7d

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

Algorithm.Sandbox/Combinatorics/Combination.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ namespace Algorithm.Sandbox.Combinatorics
88
{
99
public class Combination
1010
{
11-
public static List<List<T>> Find<T>(List<T> input, int r, bool enableRepetition)
11+
public static List<List<T>> Find<T>(List<T> input, int r, bool withRepetition)
1212
{
1313
var result = new List<List<T>>();
1414

15-
Recurse(input, r, enableRepetition, 0, new List<T>(), new HashSet<int>(), result);
15+
Recurse(input, r, withRepetition, 0, new List<T>(), new HashSet<int>(), result);
1616

1717
return result;
1818
}
1919

20-
private static void Recurse<T>(List<T> input, int r, bool enableRepetition,
20+
private static void Recurse<T>(List<T> input, int r, bool withRepetition,
2121
int k, List<T> prefix, HashSet<int> prefixIndices,
2222
List<List<T>> result)
2323
{
@@ -29,15 +29,15 @@ private static void Recurse<T>(List<T> input, int r, bool enableRepetition,
2929

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

3737
prefix.Add(input[j]);
3838
prefixIndices.Add(j);
3939

40-
Recurse(input, r, enableRepetition, j, prefix, prefixIndices, result);
40+
Recurse(input, r, withRepetition, j, prefix, prefixIndices, result);
4141

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

Algorithm.Sandbox/Combinatorics/Permutation.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ namespace Algorithm.Sandbox.Combinatorics
88
{
99
public class Permutation
1010
{
11-
public static List<List<T>> Find<T>(List<T> input, bool enableRepetition = false)
11+
public static List<List<T>> Find<T>(List<T> input, bool withRepetition = false)
1212
{
1313
var result = new List<List<T>>();
1414

15-
Recurse(input, enableRepetition, new List<T>(), new HashSet<int>(), result);
15+
Recurse(input, withRepetition, new List<T>(), new HashSet<int>(), result);
1616

1717
return result;
1818
}
1919

20-
private static void Recurse<T>(List<T> input, bool enableRepetition,
20+
private static void Recurse<T>(List<T> input, bool withRepetition,
2121
List<T> prefix, HashSet<int> prefixIndices,
2222
List<List<T>> result)
2323
{
@@ -29,39 +29,39 @@ private static void Recurse<T>(List<T> input, bool enableRepetition,
2929

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

3737
prefix.Add(input[j]);
3838
prefixIndices.Add(j);
3939

40-
Recurse(input, enableRepetition, prefix, prefixIndices, result);
40+
Recurse(input, withRepetition, prefix, prefixIndices, result);
4141

4242
prefix.RemoveAt(prefix.Count - 1);
4343
prefixIndices.Remove(j);
4444
}
4545
}
4646

47-
public static List<List<T>> Find<T>(List<T> input, bool enableRepetition,
48-
bool enableInversions) where T : IComparable
47+
public static List<List<T>> Find<T>(List<T> input, bool withRepetition,
48+
bool withInversions) where T : IComparable
4949
{
5050
var result = new List<List<T>>();
5151

52-
Recurse(input, enableRepetition, enableInversions,
52+
Recurse(input, withRepetition, withInversions,
5353
new List<T>(), new HashSet<int>(), result);
5454

5555
return result;
5656
}
5757

5858
private static void Recurse<T>(List<T> input,
59-
bool enableRepetition, bool enableInversions,
59+
bool withRepetition, bool withInversions,
6060
List<T> prefix, HashSet<int> prefixIndices,
6161
List<List<T>> result) where T : IComparable
6262
{
6363
if (prefix.Count == input.Count
64-
&& (enableInversions ||
64+
&& (withInversions ||
6565
(prefix.Count > 0 && prefix[0].CompareTo(prefix[prefix.Count - 1]) < 0)))
6666
{
6767
result.Add(new List<T>(prefix));
@@ -75,15 +75,15 @@ private static void Recurse<T>(List<T> input,
7575

7676
for (int j = 0; j < input.Count; j++)
7777
{
78-
if (prefixIndices.Contains(j) && !enableRepetition)
78+
if (prefixIndices.Contains(j) && !withRepetition)
7979
{
8080
continue;
8181
}
8282

8383
prefix.Add(input[j]);
8484
prefixIndices.Add(j);
8585

86-
Recurse(input, enableRepetition, enableInversions, prefix, prefixIndices, result);
86+
Recurse(input, withRepetition, withInversions, prefix, prefixIndices, result);
8787

8888
prefix.RemoveAt(prefix.Count - 1);
8989
prefixIndices.Remove(j);

Algorithm.Sandbox/Combinatorics/Variation.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ receives at most one element. */
1818

1919
//With repetition
2020
/* It is the number of all ways of putting r distinct balls into input.Count distinct boxes */
21-
public static List<List<T>> Find<T>(List<T> input, int r, bool enableRepetition)
21+
public static List<List<T>> Find<T>(List<T> input, int r, bool withRepetition)
2222
{
2323
var result = new List<List<T>>();
2424

25-
Recurse(input, r, enableRepetition, new List<T>(), new HashSet<int>(), result);
25+
Recurse(input, r, withRepetition, new List<T>(), new HashSet<int>(), result);
2626

2727
return result;
2828
}
2929

30-
private static void Recurse<T>(List<T> input, int r, bool enableRepetition,
30+
private static void Recurse<T>(List<T> input, int r, bool withRepetition,
3131
List<T> prefix, HashSet<int> prefixIndices,
3232
List<List<T>> result)
3333
{
@@ -39,15 +39,15 @@ private static void Recurse<T>(List<T> input, int r, bool enableRepetition,
3939

4040
for (int j = 0; j < input.Count; j++)
4141
{
42-
if (prefixIndices.Contains(j) && !enableRepetition)
42+
if (prefixIndices.Contains(j) && !withRepetition)
4343
{
4444
continue;
4545
}
4646

4747
prefix.Add(input[j]);
4848
prefixIndices.Add(j);
4949

50-
Recurse(input, r, enableRepetition, prefix, prefixIndices, result);
50+
Recurse(input, r, withRepetition, prefix, prefixIndices, result);
5151

5252
prefix.RemoveAt(prefix.Count - 1);
5353
prefixIndices.Remove(j);

0 commit comments

Comments
 (0)