fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5.  
  6. namespace ChooseLesserOfTheTwoEvils
  7. {
  8. public class Program
  9. {
  10. public static void Main()
  11. {
  12.  
  13. Console.ReadKey();
  14.  
  15. TestPick8thOnEvilA();
  16. Console.WriteLine("------");
  17. TestPick8thOnEvilB();
  18. Console.WriteLine("------");
  19.  
  20. Console.ReadKey();
  21. }
  22.  
  23.  
  24. static void TestPick8thOnEvilA()
  25. {
  26. Console.WriteLine("TestPick8thOnEvilA");
  27. long eighth = EvilCompanyA.MathProvider.Fibonacci().Skip(7).Take(1).Single();
  28. Console.WriteLine("\nEvil A's 8th fibonacci is {0}", eighth);
  29. }
  30.  
  31. static void TestPick8thOnEvilB()
  32. {
  33. Console.WriteLine("TestPick8thOnEvilB");
  34. long eighth = EvilCompanyB.MathProvider.Fibonacci().Skip(7).Take(1).Single();
  35. Console.WriteLine("\nEvil B's 8th fibonacci is {0}", eighth);
  36. }
  37. }
  38. }
  39.  
  40.  
  41.  
  42. namespace EvilCompanyA
  43. {
  44. public static class MathProvider
  45. {
  46. public static IEnumerable<long> Fibonacci()
  47. {
  48. IList<long> il = new List<long>();
  49.  
  50. long a = 0, b = 1;
  51.  
  52. for (int i = 1; i <= 50; ++i)
  53. {
  54. Console.Write("eager{0} ",i);
  55. il.Add(a);
  56. long n = a;
  57. a += b;
  58. b = n;
  59. }
  60.  
  61.  
  62.  
  63. return il;
  64. }
  65. }
  66. }
  67.  
  68. namespace EvilCompanyB
  69. {
  70. public static class MathProvider
  71. {
  72. public static IEnumerable<long> Fibonacci()
  73. {
  74. long a = 0, b = 1;
  75.  
  76. for (int i = 1; i <= 50; ++i)
  77. {
  78. Console.Write("lazy{0} ",i);
  79. yield return a;
  80. long n = a;
  81. a += b;
  82. b = n;
  83. }
  84. }
  85. }
  86. }
Success #stdin #stdout 0.04s 33928KB
stdin
Standard input is empty
stdout
TestPick8thOnEvilA
eager1 eager2 eager3 eager4 eager5 eager6 eager7 eager8 eager9 eager10 eager11 eager12 eager13 eager14 eager15 eager16 eager17 eager18 eager19 eager20 eager21 eager22 eager23 eager24 eager25 eager26 eager27 eager28 eager29 eager30 eager31 eager32 eager33 eager34 eager35 eager36 eager37 eager38 eager39 eager40 eager41 eager42 eager43 eager44 eager45 eager46 eager47 eager48 eager49 eager50 
Evil A's 8th fibonacci is 13
------
TestPick8thOnEvilB
lazy1 lazy2 lazy3 lazy4 lazy5 lazy6 lazy7 lazy8 
Evil B's 8th fibonacci is 13
------