summaryrefslogtreecommitdiff
path: root/Assets/Test/05_Recursion/Test_Recursion.cs
blob: ef72a216aee144a0d8711afeb54938d6f46aeeb9 (plain)
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
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));
    }

}