using System.Collections.Generic;
public class NumberWithSquareSumOfSquareDivisorsFinder
public int[] Find(int start, int end)
for(int i=start; i<=end; ++i)
aux = areAlreadyDivisors(j, divisors);
for(int k=0; k<divisors.Length; ++k)
square = square + divisors[k]*divisors[k];
toint = Convert.ToInt32(Math.Sqrt(square));
if((Math.Sqrt(square)-toint)==0)
Console.WriteLine("{0}", final.Length);
public bool isPrime(int number)
for(int i=2; i<number/2; ++i)
public int areAlreadyDivisors(int number, int[] divisors)
for(int i=0; i<divisors.Length; ++i)
public class MaxcodeLatinTranslator
public string Translate(string sentence)
sentence = sentence.ToLower();
string[] aux = sentence.Split(' ');
for(int i=0; i<aux.Length; ++i){
string first = aux[i].Substring(0, 1);
if(first.Equals("a") || first.Equals("e") || first.Equals("i") || first.Equals("o") || first.Equals("u"))
result = result + aux[i].Substring(1) + first;
final = final + " " + result;
else if(first.Equals("b") || first.Equals("c") || first.Equals("d") || first.Equals("f") || first.Equals("g") || first.Equals("h") || first.Equals("j") || first.Equals("k") || first.Equals("l") || first.Equals("m") || first.Equals("n") || first.Equals("p") || first.Equals("q") || first.Equals("r") || first.Equals("s") || first.Equals("t") || first.Equals("v") || first.Equals("w") || first.Equals("x") || first.Equals("y") || first.Equals("z"))
result = aux[i].Substring(1) + first + "ax";
final = final + " " + result;
final = final + " " + aux[i];
public class MaxObservable
public void Emit<T>(T data)
throw new NotImplementedException();
public void Subscribe<T>(IObserver<T> observer)
throw new NotImplementedException();
public void Unsubscribe<T>(IObserver<T> observer)
throw new NotImplementedException();
public interface IObserver<T>
public static void Main()
private static void Run()
new NumberWithSquareSumOfSquareDivisorsFinderTests().Start();
new MaxcodeLatinTranslatorTests().Start();
new MaxObservableTests().Start();
public class NumberWithSquareSumOfSquareDivisorsFinderTests
Tests.Run("NumberWithSquareSumOfSquareDivisorsFinder should", (it) =>
it.Should(() => FindAllNumbersWithTheSumOfTheirDivisorsSquaredASquareNumber(),
"Find all numbers with the sum of their divisors squared a square number");
public void FindAllNumbersWithTheSumOfTheirDivisorsSquaredASquareNumber()
var finder = new NumberWithSquareSumOfSquareDivisorsFinder();
finder.Find(42, 1000).ShouldBe(new int[] { 42, 246, 287, 728 });
finder.Find(1000, 1880).ShouldBe(new int[] { 1434, 1673, 1880 });
public class MaxcodeLatinTranslatorTests
Tests.Run("MaxcodeLatinTranslator should", (it) =>
it.Should(() => TranslateAWordStartingWithAVowel(), "Translate a word starting with a vowel");
it.Should(() => TranslateAWordStartingWithAConsonant(), "Translate a word starting with a consonant");
it.Should(() => TranslateASentence(), "Translate a sentence");
public void TranslateAWordStartingWithAVowel()
var translator = new MaxcodeLatinTranslator();
translator.Translate("orange").ShouldBe("marangeo");
public void TranslateAWordStartingWithAConsonant()
var translator = new MaxcodeLatinTranslator();
translator.Translate("jumps").ShouldBe("umpsjax");
public void TranslateASentence()
var translator = new MaxcodeLatinTranslator();
translator.Translate("i hope you are enjoying this exercise")
.ShouldBe("mai opehax ouyax marea manjoyinge histax maxercisee");
public class MaxObservableTests
Tests.Run("MaxObservable should", (it) => {
it.Should(() => NotifySubscribedObserversOfTheEmittedDataType(), "Notify subscribed observers of the emitted data type");
it.Should(() => NotNotifyUnsubscribedObservers(), "Not notify unsubscribed observers");
public void NotifySubscribedObserversOfTheEmittedDataType()
var stringObserver = new FakeObserver<string>();
var intObserver = new FakeObserver<int>();
var anotherIntObserver = new FakeObserver<int>();
var maxObservable = new MaxObservable();
maxObservable.Subscribe(stringObserver);
maxObservable.Subscribe(intObserver);
maxObservable.Subscribe(anotherIntObserver);
intObserver.WasNotifiedWith(3).ShouldBe(true, "did not notify observers of emitted value type");
anotherIntObserver.WasNotifiedWith(3).ShouldBe(true, "did not notify observers of emitted value type");
intObserver.WasNotifiedWith(20).ShouldBe(true, "did not notify observers of emitted value type");
anotherIntObserver.WasNotifiedWith(20).ShouldBe(true, "did not notify observers of emitted value type");
stringObserver.WasNotified().ShouldBe(false, "notified observers of different type than the emitted value type");
public void NotNotifyUnsubscribedObservers()
var stringObserver = new FakeObserver<string>();
var anotherStringObserver = new FakeObserver<string>();
var maxObservable = new MaxObservable();
maxObservable.Subscribe(stringObserver);
maxObservable.Subscribe(anotherStringObserver);
maxObservable.Unsubscribe(anotherStringObserver);
maxObservable.Emit("a string value");
stringObserver.WasNotifiedWith("a string value").ShouldBe(true, "did not notify subscribed observer of emitted data type");
anotherStringObserver.WasNotifiedWith("a string value").ShouldBe(false, "notified unsubscribed observer");
public class FakeObserver<T> : IObserver<T>
private HashSet<T> notifications = new HashSet<T>();
public void Notify(T data)
public bool WasNotifiedWith(T data)
return notifications.Contains(data);
public bool WasNotified()
return notifications.Any();
public static void Run(string testGroup, Action<Tests> tests)
public static void StartTests(string testGroup)
Console.WriteLine("====================================================");
Console.WriteLine(testGroup);
Console.WriteLine("====================================================");
public void Should(Action test, string testName)
Console.WriteLine(testName);
Console.WriteLine(" Passed");
Console.WriteLine(" Failed");
Console.WriteLine(" " + e.Message);
public static void EndTests()