Last active
September 12, 2017 17:24
-
-
Save kmorin/7fa0e22c867e376222f5201473b1b797 to your computer and use it in GitHub Desktop.
Revisions
-
kmorin revised this gist
Sep 12, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ private IEnumerable<int[]> getGrays(int n) { //if n is > 24 memory fails if (n <= 0 || n > 24) { return null; } var ar = new List<string> { "0", "1" }; for (var i = 2; i < 1 << n; i = i << 1) { for (var j = i - 1; j >= 0; j--) { ar.Add(ar[j]); } -
kmorin revised this gist
Sep 12, 2017 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ private IEnumerable<int[]> getGrays(int n) { //if n is 0 bits or > 5 bits, it will fail if (n <= 0 || n > 5) { return null; } var ar = new List<string> { "0", "1" }; for (var i = 2; i < 1 << n; i = i << 1) { for (var j = i - 1; j >= 0; j--) { ar.Add(ar[j]); } -
kmorin revised this gist
Jul 18, 2017 . No changes.There are no files selected for viewing
-
kmorin revised this gist
Jul 18, 2017 . 1 changed file with 20 additions and 20 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,20 +1,20 @@ private IEnumerable<int[]> getGrays(int n) { if (n <= 0) { return null; } var ar = new List<string> { "0", "1" }; for (var i = 2; i < 1 << n; i = i << 1) { for (var j = i - 1; j >= 0; j--) { ar.Add(ar[j]); } for (var j = 0; j < i; j++) { ar[j] = $"0{ar[j]}"; } for (var j = i; j < 2 * i; j++) { ar[j] = $"1{ar[j]}"; } } var returnAr = new List<int[]>(); foreach (var s in ar) { var chars = s.ToCharArray(); var tempIntArray = new int[chars.Length]; for (var i = 0; i < chars.Length; i++) { var tempInt = int.Parse(chars[i].ToString()); tempIntArray[i] = tempInt; } returnAr.Add(tempIntArray); } return returnAr; } -
kmorin revised this gist
Jul 18, 2017 . 1 changed file with 9 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,21 +1,17 @@ private IEnumerable<int[]> getGrays(int n) { if (n <= 0) { return null; } var ar = new List<string> { "0", "1" }; for (var i = 2; i < 1 << n; i = i << 1) { for (var j = i - 1; j >= 0; j--) { ar.Add(ar[j]); } for (var j = 0; j < i; j++) { ar[j] = $"0{ar[j]}"; } for (var j = i; j < 2 * i; j++) { ar[j] = $"1{ar[j]}"; } } var returnAr = new List<int[]>(); foreach (var s in ar) { var chars = s.ToCharArray(); var tempIntArray = new int[chars.Length]; for (var i = 0; i < chars.Length; i++) { var tempInt = int.Parse(chars[i].ToString()); tempIntArray[i] = tempInt; } returnAr.Add(tempIntArray); -
kmorin created this gist
Jul 18, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ private List<int[]> getGrays(int n) { if (n <= 0) return null; var ar = new List<string>(); ar.Add("0"); ar.Add("1"); for (int i = 2; i < (1<<n); i=i<<1) { for (int j = i-1; j >=0; j--) { ar.Add(ar[j]); } for (int j = 0; j < i; j++) { ar[j] = $"0{ar[j]}"; } for (int j = i; j < 2*i; j++) { ar[j] = $"1{ar[j]}"; } } var returnAr = new List<int[]>(); foreach (var s in ar) { var chars = s.ToCharArray(); var tempIntArray = new int[chars.Length]; for (int i = 0; i < chars.Length; i++) { int tempInt = int.Parse(chars[i].ToString()); tempIntArray[i] = tempInt; } returnAr.Add(tempIntArray); } return returnAr; }