-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPermutation.cs
78 lines (70 loc) · 2.49 KB
/
Permutation.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ChordFinderWPF
{
class Permutation
{
private int elementLevel = -1;
private int numberOfElements = 6;
private int[] permutationValue = new int[6];
public int[] Pitches = new int[3];
public List<int[]> Output2;
private int[] inputSet;
public int[] InputSet
{
get { return inputSet; }
set { inputSet = value; }
}
private int permutationCount = 0;
public int PermutationCount
{
get { return permutationCount; }
set { permutationCount = value; }
}
public void CalcPermutation(int k)
{
elementLevel++;
permutationValue.SetValue(elementLevel, k);
if (elementLevel == numberOfElements)
{
OutputPermutation(permutationValue);
}
else
{
for (int i = 0; i < numberOfElements; i++)
{
if (permutationValue[i] == 0)
{
CalcPermutation(i);
}
}
}
elementLevel--;
permutationValue.SetValue(0, k);
}
private void OutputPermutation(int[] value)
{
string a = string.Empty;
GuitarStrings GS = new GuitarStrings();
foreach (int i in value)
{
a += inputSet.GetValue(i - 1).ToString() + ',';
}
a = a.Substring(0, a.Length - 1);
if (a.Contains(Pitches[0].ToString()) && a.Contains(Pitches[1].ToString()) && a.Contains(Pitches[2].ToString()))
{
int[] FingerPlace = GS.GetFingerPlace(a);
if (FingerPlace[0] == -1 && FingerPlace[1] == 0 && FingerPlace[2] == 0 && FingerPlace[3] == 0 && FingerPlace[4] == -1 && FingerPlace[5] == -1)
{ }
if (!Output2.Contains(FingerPlace))
//FingerPlace[0] + "," + FingerPlace[1] + "," + FingerPlace[2] + "," + FingerPlace[3] + "," + FingerPlace[4] + "," + FingerPlace[5]))
Output2.Add(FingerPlace);
//FingerPlace[0] + "," + FingerPlace[1] + "," + FingerPlace[2] + "," + FingerPlace[3] + "," +
// FingerPlace[4] + "," + FingerPlace[5] + "\t";
}
PermutationCount++;
}
}
}