summaryrefslogtreecommitdiff
path: root/Assets/Test/05_Recursion/Test_Recursion.cs
diff options
context:
space:
mode:
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));
+ }
+
+}