summaryrefslogtreecommitdiff
path: root/Assets/Test/05_Recursion/Test_Recursion.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-06-21 15:53:42 +0800
committerchai <chaifix@163.com>2021-06-21 15:53:42 +0800
commitcc475a8b16b0e9323623c6532e114dceeb64353a (patch)
tree0d57c6afd973ed03a66e614038d9c9ef1acb790b /Assets/Test/05_Recursion/Test_Recursion.cs
parent2283e4eda5ed0ef8760bef495b6ca60297b36404 (diff)
+recursions
Diffstat (limited to 'Assets/Test/05_Recursion/Test_Recursion.cs')
-rw-r--r--Assets/Test/05_Recursion/Test_Recursion.cs30
1 files changed, 30 insertions, 0 deletions
diff --git a/Assets/Test/05_Recursion/Test_Recursion.cs b/Assets/Test/05_Recursion/Test_Recursion.cs
new file mode 100644
index 0000000..ef72a21
--- /dev/null
+++ b/Assets/Test/05_Recursion/Test_Recursion.cs
@@ -0,0 +1,30 @@
+using System.Collections;
+using System.Collections.Generic;
+using AlgorithmCollection;
+using AlgorithmCollection.Recursion;
+using UnityEngine;
+
+public class Test_Recursion : MonoBehaviour
+{
+ void Start()
+ {
+ TestPermutations();
+ }
+
+ void TestPermutations()
+ {
+ // 全排列
+ Debug.Log("====全排列====");
+ List<char> data = new List<char> { 'a', 'b', 'c' };
+ int count = 0;
+ foreach (List<char> p in RecursionHelper.Permutations(data))
+ {
+ count++;
+ string content = "";
+ p.ForEach((char c) => content += c + " ");
+ Debug.Log(content);
+ }
+ Debug.Assert(count == Algorithms.Factorial(data.Count));
+ }
+
+}