-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChallenge8.cs
61 lines (49 loc) · 1.59 KB
/
Challenge8.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//TODO############################################
//Challenge 8 - Headache
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Challenge8
{
static string InputFileName = @"/Inputs/Challenge 8/codes.txt";
static string OutputFileNameDown = @"/Outputs/Challenge 8/clean-codes-down.txt";
static string OutputFileNameTop = @"/Outputs/Challenge 8/clean-codes-top.txt";
static string OutputFileName = @"/Outputs/Challenge 8/map.txt";
static List<KeyValuePair<List<string>, List<int>>> Pieces = new List<KeyValuePair<List<string>, List<int>>>();
static void Main()
{
string[] input = File.ReadAllLines(InputFileName).Where(x => x != string.Empty).ToArray();
List<string> linesToUp = GetLinesFromDirection(input, true);
ShowLinesConsole(linesToUp);
Console.ReadLine();
}
static List<string> GetLinesFromDirection(string[] lines, bool toUp)
{
List<string> l = new List<string>();
int total = lines.Length;
if (toUp)
{
for (int i = 0; i < total; i++)
{
string line = lines[i];
if (line.Contains("P*"))
{
l.Add(line);
for (int c = i - 1; c >= 0; c--)
{
l.Add(lines[c]);
}
}
}
}
return l;
}
static void ShowLinesConsole(List<string> lines)
{
foreach (var line in lines)
{
Console.WriteLine(line);
}
}
}