diff --git a/Video.xaml.cs b/Video.xaml.cs index 154b600..ca84638 100644 --- a/Video.xaml.cs +++ b/Video.xaml.cs @@ -92,7 +92,7 @@ namespace VideoConcat { string mp4Path = $"{Directory.GetCurrentDirectory()}\\temp\\"; - DirectoryInfo directoryInfo = new DirectoryInfo(mp4Path); + DirectoryInfo directoryInfo = new(mp4Path); FileInfo[] files = directoryInfo.GetFiles("*.mp4"); // 获取指定目录下的所有 txt 文件 @@ -321,7 +321,7 @@ namespace VideoConcat { ls.Add(new List(item.Value)); } - List> permutations = CalculatePermutations(ls); + List> permutations = GenerateAllPermutations(ls); return permutations; @@ -352,6 +352,32 @@ namespace VideoConcat + return result; + } + + + static List> GenerateAllPermutations(List> ballInBoxes) + { + if (ballInBoxes.Count == 0) + { + return [[]]; + } + + List firstBoxBall = ballInBoxes[0]; + List> remainingBoxes = ballInBoxes.GetRange(1, ballInBoxes.Count-1); + + List> subPermutations = GenerateAllPermutations(remainingBoxes); + + List> result = []; + foreach (var firstItem in firstBoxBall) + { + foreach (var subPermutation in subPermutations) + { + List newPermutation = [firstItem, .. subPermutation]; + result.Add(newPermutation); + } + } + return result; } }