Skip to content

Instantly share code, notes, and snippets.

@ff8c00
Last active January 16, 2018 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ff8c00/47219918477410e4b5de7cc4cffac812 to your computer and use it in GitHub Desktop.
Save ff8c00/47219918477410e4b5de7cc4cffac812 to your computer and use it in GitHub Desktop.
Reddit Daily Programmer 347 Easy
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