Last active
January 16, 2018 16:20
-
-
Save ff8c00/47219918477410e4b5de7cc4cffac812 to your computer and use it in GitHub Desktop.
Reddit Daily Programmer 347 Easy
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; | |
namespace Reddit | |
{ | |
internal static class Easy | |
{ | |
internal static void Run() | |
{ | |
string[] input = new string[] | |
{ | |
"15 18", | |
"13 16", | |
"9 12", | |
"3 4", | |
"17 20", | |
"9 11", | |
"17 18", | |
"4 5", | |
"5 6", | |
"4 5", | |
"5 6", | |
"13 16", | |
"2 3", | |
"15 17", | |
"13 14" | |
}; | |
bool[] output = new bool[0]; | |
for (int i = 0; i < input.Length; i++) | |
{ | |
string[] array = input[i].Split(' '); | |
int index = int.Parse(array[0]); | |
int size = int.Parse(array[1]); | |
if (output.Length < size) | |
{ | |
Array.Resize(ref output, size); | |
} | |
for (int j = index; j < size; j++) | |
{ | |
output[j] = true; | |
} | |
} | |
int count = 0; | |
for (int i = 0; i < output.Length; i++) | |
{ | |
if (output[i] == true) | |
{ | |
count = count + 1; | |
} | |
} | |
Console.Write(count); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment