public static class Robber
public const string C = "bcdfghjklmnpqrstvwxyz";
public static string Decode(string s)
return t + (s.Length > 2 && C.Contains(u) && s.Substring(0, 3) == t + "o" + u ? Decode(s.Substring(3)) : Decode(s.Substring(1)));
public static string Encode(string s)
return t + (C.Contains(u) ? "o" + u : "") + (s.Length > 1 ? Encode(s.Substring(1)) : "");
public void DecodeTest1()
Assert.AreEqual("Rövarspråket", Robber.Decode("Rorövovarorsospoproråkoketot"));
public void DecodeTest2()
Assert.AreEqual("Jag talar rövarspråket.", Robber.Decode("Jojagog totalolaror rorövovarorsospoproråkoketot."));
public void EncodeTest1()
Assert.AreEqual("Rorövovarorsospoproråkoketot", Robber.Encode("Rövarspråket"));
public void EncodeTest2()
Assert.AreEqual("Jojagog totalolaror rorövovarorsospoproråkoketot.", Robber.Encode("Jag talar rövarspråket."));
public static void Main()
var robberTests = new RobberTests();
var methods = typeof(RobberTests).GetMethods();
foreach (var method in methods)
if (method.DeclaringType == typeof(object)) continue;
method.Invoke(robberTests, null);
Console.WriteLine("pass {0}", method.Name);
Console.WriteLine("fail {0}", method.Name);
Console.WriteLine(e.Message);
if (e.InnerException != null)
Console.WriteLine(e.InnerException.Message);