Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using System.Linq;
- using System;
- public class Kata
- {
- public static int Find(int[] integers)
- {
- List<int> Oddlist = new List<int>();
- List<int> EvenList = new List<int>();
- int result = 0;
- foreach(int i in integers)
- {
- if(i % 2 == 0)
- {
- EvenList.Add(i);
- }
- else
- {
- Oddlist.Add(i);
- }
- }
- if(Oddlist.Count == 1)
- {
- result = Oddlist[0];
- }
- if(EvenList.Count == 1)
- {
- result = EvenList[0];
- }
- else
- result = 0;
- return result;
- }
- }
Add Comment
Please, Sign In to add comment