Ja. Det er C#.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace Skizonymer
{
public class Program
{
public static void Main(string[] args)
{
Regex orderRegex = new Regex(@"^[0-9]\.\s+");
IEnumerable<string> words =
File.ReadAllLines(@"RO2012.opslagsord.med.homnr.og.ordklasse.txt")
.Select(l => l.Split(';'))
.Select(l => orderRegex.Replace(l[0], "")).ToList();
HashSet<string> wordLookup = new HashSet<string>(words);
int count = 0;
foreach (string word in words)
{
string doubleWord = word + word;
for (int i = 1; i < doubleWord.Length - 1; i++)
{
string firstPart = doubleWord.Substring(0, i);
if (firstPart != word)
{
string secondPart = doubleWord.Substring(i);
if (wordLookup.Contains(firstPart) &&
wordLookup.Contains(secondPart))
{
count++;
Console.WriteLine("{0} og {1} giver {2}",
firstPart, secondPart, doubleWord);
}
}
}
}
Console.WriteLine("Fandt " + count);
Console.ReadLine();
}
}
}
--
Andreas