using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
public static class Implementations
public static void GreenTea(int n)
var divisibleBy3 = (n % 3) == 0;
var divisibleBy5 = (n % 5) == 0;
var prints = divisibleBy3 || divisibleBy5;
public static IEnumerable<T> FirstHalf<T>(this IEnumerable<T> tt)
if (tt is ICollection<T>){
var size = Math.Floor(tt.Count() / 2.0);
var cursor=tt.GetEnumerator();
while ((size-- != 0) && cursor.MoveNext()){
yield return cursor.Current;
foreach(var item in tt.ToList().FirstHalf()){
public static void Main()
AssertGreenTeaIsCorrect(1020);
AssertGreenTeaIsCorrect(102);
AssertGreenTeaIsCorrect(10);
AssertGreenTeaIsCorrect(4);
AssertFirstHalfIsCorrect(new string [] { "North", "South", "East", "West" });
AssertFirstHalfIsCorrect(new string [] { "red", "green", "blue" });
AssertFirstHalfIsCorrect((new string [] { "North", "South", "East", "West" }).Select(i=>i));
AssertFirstHalfIsCorrect((new string [] { "red", "green", "blue" }).Select(i=>i));
Console.WriteLine("All tests succeeded.");
public static void AssertGreenTeaIsCorrect(int n)
Implementations.GreenTea(n);
public static void AssertFirstHalfIsCorrect(IEnumerable<string> tt)
var result = tt.FirstHalf();
if (tt.SequenceEqual(new string [] { "North", "South", "East", "West" }))
Assert.IsTrue(result.SequenceEqual(new string [] { "North", "South" }));
else if (tt.SequenceEqual(new string [] { "red", "green", "blue" }))
Assert.IsTrue(result.SequenceEqual(new string [] { "red" }));
Assert.Fail("No benchmark for sequence {0}.", string.Join(", ", tt));