public static void Main() { var code = new Code(InputFileReader.ReadAllLines("Input.txt")[0]); var res = code.DecompressAndCount2(); Console.WriteLine(res); Console.ReadLine(); }
static void Main(string[] args) { var strings = InputFileReader.ReadAllLines("Input.txt"); var unlocker = new Unlocker(strings); Console.WriteLine(unlocker.GenerateSectorSum()); unlocker.GetSectorIdOfRequiredRoom(); Console.ReadLine(); }
static void Main(string[] args) { var operations = InputFileReader.ReadAllLines("Input.txt"); var op = new Operator(operations); op.Run(); Console.WriteLine(op.GetResult('a')); Console.ReadLine(); }
public static void Main() { _rawTriangles = InputFileReader.ReadAllLines("Input.txt"); _triangles = new List <Triangle>(); Task1(); _triangles.Clear(); Task2(); Console.ReadLine(); }
public static void Main() { var unlocker = new Unlocker(); var unlocker2 = new Unlocker(2); var inputCodes = InputFileReader.ReadAllLines("Input.txt"); Console.WriteLine("Task1: " + unlocker.GetCode(inputCodes)); Console.WriteLine("Task2: " + unlocker2.GetCode(inputCodes)); Console.ReadLine(); }
static void Main(string[] args) { var strings = InputFileReader.ReadAllLines("Input.txt"); var convertedStrings = InputTransposer.Convert(strings); var simplifiedString1 = Simplifier.Simplify(convertedStrings); var simplifiedString2 = Simplifier.Simplify(convertedStrings, false); Console.WriteLine("Task 1: " + simplifiedString1); Console.WriteLine("Task 2: " + simplifiedString2); Console.ReadLine(); }
static void Main(string[] args) { var input = InputFileReader.ReadAllLines("Input.txt"); var actions = new List <int>(); foreach (var s in input) { actions.Add(int.Parse(s)); } // Task 1: var res0 = 0; foreach (var action in actions) { res0 += action; } // Task 2: var freq = 0; var res = 0; var allFreqs = new HashSet <int>(); allFreqs.Add(freq); var notFound = true; while (notFound) { foreach (var action in actions) { freq += action; if (!allFreqs.Add(freq)) { notFound = false; res = freq; break; } } } // Output: Console.WriteLine(res0); Console.WriteLine(res); Console.ReadLine(); }
static void Main(string[] args) { var screen = new Screen(6, 50); var commands = InputFileReader.ReadAllLines("Input.txt"); foreach (var command in commands) { screen.ExecuteCommand(command); } var count = screen.GetCount(); var screenOutput = screen.GetScreen(); Console.WriteLine(count); foreach (var s in screenOutput) { Console.WriteLine(s); } Console.ReadLine(); }
static void Main(string[] args) { var input = InputFileReader.ReadAllLines("Input.txt"); var tlsCount = 0; var sslCount = 0; foreach (var s in input) { var address = new IpAddress(s); if (address.SupportsTls()) { tlsCount++; } if (address.SupportsSsl()) { sslCount++; } } Console.WriteLine("TLS count: " + tlsCount); Console.WriteLine("SSL count: " + sslCount); Console.ReadLine(); }
static void Main(string[] args) { var instructions = InputFileReader.ReadAllLines("Input.txt"); var bots = new List <Bot>(); foreach (var instruction in instructions) { var instructionDetails = instruction.Split(" "); if (instructionDetails[0].Equals("bot")) { var name = instructionDetails[0] + instructionDetails[1]; var lower = instructionDetails[5] + int.Parse(instructionDetails[6]); var higher = instructionDetails[10] + int.Parse(instructionDetails[11]); if (lower.Contains("output")) { bots.Add(new Bot() { Name = lower }); } if (higher.Contains("output")) { bots.Add(new Bot() { Name = higher }); } bots.Add(new Bot() { Name = name, Higher = higher, Lower = lower }); } } foreach (var instruction in instructions) { var instructionDetails = instruction.Split(" "); if (instructionDetails[0].Equals("value")) { var value = int.Parse(instructionDetails[1]); var target = instructionDetails[4] + int.Parse(instructionDetails[5]); bots.Where(b => b.Name.Equals(target)).Take(1).First().Add(value); } } while (true) { var actionCount = 0; foreach (var bot in bots) { if (bot.Name.Contains("bot") && bot.IsFull()) { if (bot.GetLowerValue() == 17 && bot.GetHigherValue() == 61) { Console.WriteLine(bot.Name); } bots.Where(b => b.Name.Equals(bot.Lower)).Take(1).First().Add(bot.GetLowerValue()); bots.Where(b => b.Name.Equals(bot.Higher)).Take(1).First().Add(bot.GetHigherValue()); bot.Clear(); actionCount++; } } if (actionCount == 0) { break; } } var result = bots.Where(b => b.Name.Equals("output0")).Take(1).First()._bucket[0] * bots.Where(b => b.Name.Equals("output1")).Take(1).First()._bucket[0] * bots.Where(b => b.Name.Equals("output2")).Take(1).First()._bucket[0]; Console.WriteLine(result); Console.ReadLine(); }
static void Main(string[] args) { var c = _reverse ? "fbgdceah".ToCharArray() : "abcdefgh".ToCharArray(); var input = InputFileReader.ReadAllLines("Input.txt"); var operations = new List <IOperation>(); foreach (var str in input) { var s = str.Split(" "); switch (s[0]) { case "swap": { if (s[1].Equals("position")) { var swap = new PosSwap(int.Parse(s[2]), int.Parse(s[5])); operations.Add(swap); } else { var swap = new LetterSwap(s[2][0], s[5][0]); operations.Add(swap); } break; } case "rotate": { if (s[1].Equals("left")) { if (_reverse) { var rot = new Rotate(+int.Parse(s[2]), 0); operations.Add(rot); } else { var rot = new Rotate(-int.Parse(s[2]), 0); operations.Add(rot); } break; } if (s[1].Equals("right")) { if (_reverse) { var rot = new Rotate(-int.Parse(s[2]), 0); operations.Add(rot); } else { var rot = new Rotate(+int.Parse(s[2]), 0); operations.Add(rot); } break; } var pos = s[6][0]; var rot1 = new Rotate(pos, pos, _reverse); operations.Add(rot1); break; } case "_reverse": { var rev = new Reverse(int.Parse(s[2]), int.Parse(s[4])); operations.Add(rev); break; } case "move": { if (_reverse) { var mov = new Move(int.Parse(s[5]), int.Parse(s[2])); operations.Add(mov); } else { var mov = new Move(int.Parse(s[2]), int.Parse(s[5])); operations.Add(mov); } break; } } } if (_reverse) { for (var i = 0; i < operations.Count; i++) { operations[operations.Count - 1 - i].Do(ref c); } } else { foreach (var operation in operations) { operation.Do(ref c); } } Console.WriteLine(c); Console.ReadLine(); }
static void Main(string[] args) { var input = InputFileReader.ReadAllLines("Input.txt"); var max = uint.MaxValue; var boundarys = new uint[input.Length, 2]; for (var i = 0; i < input.Length; i++) { var split = input[i].Split("-"); boundarys[i, 0] = uint.Parse(split[0]); boundarys[i, 1] = uint.Parse(split[1]); } var list = new List <Tuple <uint, uint> >(); for (var i1 = 0; i1 < boundarys.Length / 2; i1++) { list.Add(new Tuple <uint, uint>(boundarys[i1, 0], boundarys[i1, 1])); } var count = 0; var sortedList = list.OrderBy(i => i.Item1).ThenBy(i => i.Item2).ToList(); var toBeRemoved = new List <int>(); do { toBeRemoved.Clear(); for (var i = 0; i < sortedList.Count - 1; i++) { if (!toBeRemoved.Contains(i) && sortedList[i + 1].Item2 <= sortedList[i].Item2) { toBeRemoved.Add(i + 1); } } for (var i = toBeRemoved.Count - 1; i >= 0; i--) { sortedList.RemoveAt(toBeRemoved[i]); } } while (toBeRemoved.Count > 0); uint idx = 0; var idxList = 0; var goneThrough = false; while (idx < max && !goneThrough) { uint current = sortedList[idxList].Item1; for (var i = idx; i < current; i++) { if (count == 0) { Console.WriteLine("First: " + i); } count++; } current = sortedList[idxList].Item2; if (current == uint.MaxValue) { idx = current; break; } while (true) { if (idxList + 1 == sortedList.Count) { idx = current + 1; goneThrough = true; break; } idxList++; var endOfNext = sortedList[idxList].Item2; if (current >= sortedList[idxList].Item1 && current <= endOfNext) { current = endOfNext; } else { idx = current + 1; break; } } } for (var i = idx; i < max; i++) { count++; } Console.WriteLine("Total count: " + count); Console.ReadLine(); }
static void Main(string[] args) { var input = InputFileReader.ReadAllLines("Input.txt"); var input = new[] { "", "" }; var inputList = input.ToList(); var pairNotFound = true; var res1 = ""; var res2 = ""; while (pairNotFound) { var s1 = inputList[0]; foreach (var s in inputList) { if (s.Equals(s1)) { continue; } if (hasOneDifference(s1, s)) { res1 = s1; res2 = s; pairNotFound = false; break; } } inputList.Remove(s1); } var res = returnResult(res1, res2); /* * var inputAnalytics = new List<Dictionary<char, int>>(); * * foreach (var s in input) * { * var dict = new Dictionary<char,int>(); * foreach (var c in s) * { * if(dict.TryGetValue(c, out var k)) * { * dict.Remove(c); * var count = k + 1; * dict.Add(c,count); * } * else * { * dict.Add(c, 1); * } * } * inputAnalytics.Add(dict); * } * * var count2 = 0; * var count3 = 0; * * foreach (var inputAnalytic in inputAnalytics) * { * var keys = inputAnalytic.Keys; * var has3 = false; * var has2 = false; * foreach (var key in keys) * { * * if (inputAnalytic.TryGetValue(key, out var count)) * { * if (count == 2 && !has2) * { * count2++; * has2 = true; * } * * if (count == 3 && !has3) * { * count3++; * has3 = true; * } * } * } * } * var res = count2*count3; */ Console.WriteLine(res); Console.ReadLine(); }