From cc475a8b16b0e9323623c6532e114dceeb64353a Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 21 Jun 2021 15:53:42 +0800 Subject: +recursions --- Assets/Test/05_Recursion/Test_Recursion.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Assets/Test/05_Recursion/Test_Recursion.cs (limited to 'Assets/Test/05_Recursion/Test_Recursion.cs') 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 data = new List { 'a', 'b', 'c' }; + int count = 0; + foreach (List p in RecursionHelper.Permutations(data)) + { + count++; + string content = ""; + p.ForEach((char c) => content += c + " "); + Debug.Log(content); + } + Debug.Assert(count == Algorithms.Factorial(data.Count)); + } + +} -- cgit v1.1-26-g67d0