Created
October 27, 2020 00:44
-
-
Save auycro/91476b0d316fff78c4b7d1f2d4574bea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
var test_data = Init(); | |
test_data.ForEach((x)=>{ | |
if (IsBothConditions(x)){ | |
System.Console.WriteLine("baz"); | |
} else if (IsContainsByThree(x)){ | |
System.Console.WriteLine("bar"); | |
} else if (IsMultiplyByThree(x)){ | |
System.Console.WriteLine("foo"); | |
} else { | |
System.Console.WriteLine(x); | |
} | |
}); | |
} | |
public static List<int> Init(){ | |
var result = new List<int>(); | |
for(int i=0;i<50;i++){ | |
result.Add(i+1); | |
} | |
return result; | |
} | |
public static bool IsMultiplyByThree(int input){ | |
if ((input % 3) == 0){ | |
return true; | |
} | |
return false; | |
} | |
public static bool IsContainsByThree(int input){ | |
var cond = input.ToString(); | |
if (cond.Contains(("3"))){ | |
return true; | |
} | |
return false; | |
} | |
public static bool IsBothConditions(int input){ | |
if (IsContainsByThree(input) && IsMultiplyByThree(input)){ | |
return true; | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment