Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- public class Kata
- {
- public static int DontGiveMeFive(int start, int end)
- {
- //Generate Range of integers based on input
- //Filter out 5's
- //Return count of remaining integers
- List <int> intList = new List<int>();
- int result = 0;
- bool hasFive = false;
- for(int x = start;x < end;x++)
- {
- intList.Add(x);
- }
- result = intList.Count;
- for(int i = 0;i < intList.Count;i++)
- {
- hasFive = false;
- string numString = intList[i].ToString();
- char[] numChars = numString.ToCharArray();
- for(int a = 0;a < numChars.Length;a++)
- {
- if(numChars[a] == '5')
- {
- hasFive = true;
- }
- }
- if(hasFive == true)
- {
- result --;
- }
- }
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement