Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- public class Kata {
- public static int NumberOfPairs(string[] gloves) {
- int pairCounter = 0;
- List<string> glovesList = new List<string>(gloves);
- for(int x = 0;x < glovesList.Count;x++)
- {
- for(int y = x + 1;y < glovesList.Count;y++)
- {
- if(glovesList[y] == glovesList[x])
- {
- glovesList.RemoveAt(glovesList.IndexOf(glovesList[y]));
- pairCounter++;
- }
- }
- glovesList.RemoveAt(glovesList.IndexOf(glovesList[x]));
- }
- return pairCounter;
- }
- }
Add Comment
Please, Sign In to add comment