Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Kata
- {
- public static bool IsHollow(int[] x)
- {
- int count = x.Length;
- int preceeding = 0;
- int following = 0;
- int zeroes = 0;
- bool result = false;
- for(int a = 0;a < count;a++)
- {
- if(x[a] != 0)
- {
- preceeding++;
- }
- if(x[a] == 0)
- {
- break;
- }
- }
- for(int b = count - 1;b > 0;b--)
- {
- if(x[b] != 0)
- {
- following++;
- }
- if(x[b] == 0)
- {
- break;
- }
- }
- for(int c = 0;c < count;c++)
- {
- if(x[c] == 0)
- {
- zeroes++;
- }
- }
- if(following == preceeding && zeroes >= 3)
- {
- result = true;
- }
- else
- {
- result = false;
- }
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement