fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. [Flags]
  6. public enum TypeMoEnum : long
  7. {
  8. NotDefined = 0,
  9. MO = 1,
  10. Federal = 2,
  11. Laboratory = 4,
  12. CallCentre = 8,
  13. ForRouteCard = 16
  14. }
  15.  
  16. public class Test
  17. {
  18. private static IEnumerable<TypeMoEnum> With(TypeMoEnum value)
  19. {
  20. long lim = Enum.GetValues(typeof(TypeMoEnum)).OfType<TypeMoEnum>().Max(x => (long)x) << 1;
  21. long val = (long)value, step = val<<1;
  22.  
  23. for (long l=val; l<lim; l+=step)
  24. for (long r=0; r<val; ++r)
  25. yield return (TypeMoEnum)(l|r);
  26. }
  27.  
  28. public static void Main()
  29. {
  30. foreach(var x in With(TypeMoEnum.Laboratory))
  31. Console.WriteLine(x);
  32. }
  33. }
Success #stdin #stdout 0.01s 131776KB
stdin
Standard input is empty
stdout
Laboratory
MO, Laboratory
Federal, Laboratory
MO, Federal, Laboratory
Laboratory, CallCentre
MO, Laboratory, CallCentre
Federal, Laboratory, CallCentre
MO, Federal, Laboratory, CallCentre
Laboratory, ForRouteCard
MO, Laboratory, ForRouteCard
Federal, Laboratory, ForRouteCard
MO, Federal, Laboratory, ForRouteCard
Laboratory, CallCentre, ForRouteCard
MO, Laboratory, CallCentre, ForRouteCard
Federal, Laboratory, CallCentre, ForRouteCard
MO, Federal, Laboratory, CallCentre, ForRouteCard