using System.Collections.Generic;
public static void Main()
Console.WriteLine(isSpliceJoin("abaca", 2, "abaac"));
private static bool isSpliceJoin(String text, int len, String target)
List<string> substring = getSubstring(text, len);
return permute(substring, 0, substring.Count - 1, target);
private static List<string> getSubstring(string text, int len)
List<string> ret = new List<string>();
int textLen = text.Length;
subCounter = (textLen - loopIndex) > len ? len : textLen - loopIndex;
ret.Add(text.Substring(loopIndex, subCounter));
while (loopIndex != textLen);
private static bool permute(List<string> str, int start, int end, String target)
return (string.Join("", str.ToArray()) == target);
for (int i = start; i <= end; i++)
str = swap(str, start, i);
bool ret = permute(str, start + 1, end, target);
str = swap(str, start, i);
public static List<string> swap(List<string> a, int i, int j)