Exemplo n.º 1
0
        public void Setup(PuzzleAttribute info)
        {
            var input = File.ReadAllText(info.DataFilePath).Replace("\r", "")
                        .Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

            Instructions = input.Select(s => Instruction.FromString(s)).ToList();
        }
Exemplo n.º 2
0
 public void Setup(PuzzleAttribute info)
 {
     Indices = File.ReadAllText(info.DataFilePath)
               .Replace("F", "0").Replace("L", "0").Replace("R", "1").Replace("B", "1")
               .Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries)
               .Select(n => Convert.ToInt32(n, 2)).ToList();
 }
Exemplo n.º 3
0
 public void Setup(PuzzleAttribute info)
 {
     numbers = new List <int>()
     {
         0, 1, 4, 13, 15, 12, 16
     };
     //numbers = new List<int>() { 0, 3, 6 };
 }
Exemplo n.º 4
0
 public void Setup(PuzzleAttribute info)
 {
     Numbers = File.ReadAllText(info.DataFilePath)
               .Split('\n').ToList()
               .ConvertAll(n => n.Trim()).Where(n => n != "").ToList()
               .ConvertAll(n => int.Parse(n))
               .OrderBy(i => i).ToList();
 }
Exemplo n.º 5
0
        public void Setup(PuzzleAttribute info)
        {
            var input = File.ReadAllText(info.DataFilePath)
                        .Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

            earliestTime = int.Parse(input[0]);
            busTimes     = input[1].Split(',').Select(s => s == "x" ? int.MaxValue : int.Parse(s)).ToList();
        }
Exemplo n.º 6
0
        public void Setup(PuzzleAttribute info)
        {
            var inp = File.ReadAllText(info.DataFilePath)
                      .Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries)
                      .Select(i => i.Trim());

            var reg = new Regex(@"(\d+)-(\d+)\s(.):\s(.+)");

            Input = new List <GroupCollection>();
            foreach (var i in inp)
            {
                Input.Add(reg.Matches(i)[0].Groups);
            }
        }
Exemplo n.º 7
0
        public void Setup(PuzzleAttribute info)
        {
            var input = File.ReadAllText(info.DataFilePath).Replace("\r", "")
                        .Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

            width  = input[0].Length;
            height = input.Length;

            SeatsP1 = new Seat[width, height];
            SeatsP2 = new Seat[width, height];

            var y = 0;
            var x = 0;

            foreach (var line in input)
            {
                foreach (var ch in line)
                {
                    if (ch == 'L')
                    {
                        SeatsP1[x, y] = new Seat(x, y, width, height, ref SeatsP1);
                        SeatsP2[x, y] = new Seat(x, y, width, height, ref SeatsP2);
                    }
                    x++;
                }
                y++;
                x = 0;
            }

            for (y = 0; y < height; y++)
            {
                for (x = 0; x < width; x++)
                {
                    SeatsP1[x, y]?.SetSurrounding(SeatsP1);
                    SeatsP2[x, y]?.SetSurrounding(SeatsP2);
                }
            }
        }
Exemplo n.º 8
0
        public void Setup(PuzzleAttribute info)
        {
            var lines = File.ReadAllText(info.DataFilePath).Replace("bags", "bag").Replace(".", "")
                        .Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var l in lines)
            {
                var node = new BagNode()
                {
                    Name = l.Substring(0, l.IndexOf(" contain "))
                };
                Rules.Add(node);
                if (node.Name == "shiny gold bag")
                {
                    Shiny = node;
                }
            }

            for (var i = 0; i < lines.Length; i++)
            {
                var node = Rules[i];

                if (!lines[i].Contains("no other bag"))
                {
                    var cS = lines[i].Split(new[] { " contain " }, StringSplitOptions.RemoveEmptyEntries)[1]
                             .Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var s in cS)
                    {
                        var num   = int.Parse(s.Split(' ')[0]);
                        var name  = s.Substring(s.IndexOf(' ') + 1);
                        var cNode = Rules.First(c => c.Name == name);
                        node.Children.Add((cNode, num));
                        cNode.Parents.Add(node);
                    }
                }
            }
        }
Exemplo n.º 9
0
 public void Setup(PuzzleAttribute info)
 {
     instructions = File.ReadAllText(info.DataFilePath).Replace("\r", "")
                    .Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
 }
Exemplo n.º 10
0
 public void Setup(PuzzleAttribute info)
 {
     Computer = new ComputerD8(File.ReadAllLines(info.DataFilePath));
 }
Exemplo n.º 11
0
 public void Setup(PuzzleAttribute info)
 {
     input = File.ReadAllText(info.DataFilePath).Replace("\r", "")
             .Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries)
             .Select(c => long.Parse(c)).ToList();
 }
Exemplo n.º 12
0
 public void Setup(PuzzleAttribute info)
 {
     Map = new TreeMap(File.ReadAllText(info.DataFilePath));
 }
Exemplo n.º 13
0
        public void Setup(PuzzleAttribute info)
        {
            var input = File.ReadAllText(info.DataFilePath).Trim();

            groups = input.Split(new[] { "\n\n" }, StringSplitOptions.RemoveEmptyEntries).ToList();
        }
Exemplo n.º 14
0
 public void Setup(PuzzleAttribute info)
 {
     nums = File.ReadAllText(info.DataFilePath).Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries)
            .Select(s => long.Parse(s)).ToList();
 }
Exemplo n.º 15
0
 public void Setup(PuzzleAttribute info)
 {
     var input = File.ReadAllText(info.DataFilePath);
 }
Exemplo n.º 16
0
 public void Setup(PuzzleAttribute info)
 {
     Passports = File.ReadAllText(info.DataFilePath)
                 .Split(new[] { "\n\n" }, StringSplitOptions.RemoveEmptyEntries);
 }