-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
93 changed files
with
365 additions
and
1,575 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
File renamed without changes.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,77 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace AdventOfCode | ||
{ | ||
internal static class Program | ||
{ | ||
private static string _input; | ||
|
||
private static Direction _currentDirection = Direction.North; | ||
|
||
private static int _distanceVertical; | ||
private static int _distanceHorizontal; | ||
|
||
private static bool _crossingFound; | ||
private static Point _firstCrossed; | ||
private static readonly List<Point> Visited = new List<Point>(); | ||
|
||
private static void Main() | ||
{ | ||
_input = File.ReadAllText("../../input.txt"); | ||
|
||
var instructions = _input.Split(new[] {", "}, StringSplitOptions.None); | ||
|
||
foreach (var i in instructions) | ||
{ | ||
if (i[0] == 'R') _currentDirection++; | ||
else _currentDirection--; | ||
|
||
if (_currentDirection > (Direction) 4) _currentDirection = Direction.North; | ||
if (_currentDirection < (Direction) 1) _currentDirection = Direction.West; | ||
|
||
var steps = int.Parse(i.Substring(1)); | ||
|
||
for (var j = 1; j <= steps; j++) | ||
{ | ||
switch (_currentDirection) | ||
{ | ||
case Direction.North: | ||
_distanceVertical++; | ||
break; | ||
case Direction.West: | ||
_distanceHorizontal--; | ||
break; | ||
case Direction.South: | ||
_distanceVertical--; | ||
break; | ||
case Direction.East: | ||
_distanceHorizontal++; | ||
break; | ||
default: | ||
throw new ArgumentOutOfRangeException(); | ||
} | ||
|
||
var point = new Point(_distanceHorizontal, _distanceVertical); | ||
|
||
if (!_crossingFound) | ||
{ | ||
if (Visited.Contains(point)) | ||
{ | ||
_firstCrossed = point; | ||
_crossingFound = true; | ||
} | ||
} | ||
|
||
Visited.Add(point); | ||
} | ||
} | ||
|
||
Console.WriteLine("Answers: "); | ||
Console.WriteLine("*: " + Visited.Last().Distance); | ||
Console.Write("**: " + _firstCrossed.Distance); | ||
|
||
Console.Read(); | ||
} | ||
} | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace AdventOfCode | ||
{ | ||
internal static class Program | ||
{ | ||
private static string _input = ""; | ||
|
||
private static Direction _currentDirection = Direction.North; | ||
|
||
private static int _distanceVertical; | ||
private static int _distanceHorizontal; | ||
|
||
private static bool _crossingFound; | ||
private static Point? _firstCrossed; | ||
private static readonly List<Point> Visited = new List<Point>(); | ||
|
||
private static void Main() | ||
{ | ||
_input = File.ReadAllText("2016/01/input.txt"); | ||
|
||
var instructions = _input.Split(new[] {", "}, StringSplitOptions.None); | ||
|
||
foreach (var i in instructions) | ||
{ | ||
if (i[0] == 'R') _currentDirection++; | ||
else _currentDirection--; | ||
|
||
if (_currentDirection > (Direction) 4) _currentDirection = Direction.North; | ||
if (_currentDirection < (Direction) 1) _currentDirection = Direction.West; | ||
|
||
var steps = int.Parse(i.Substring(1)); | ||
|
||
for (var j = 1; j <= steps; j++) | ||
{ | ||
switch (_currentDirection) | ||
{ | ||
case Direction.North: | ||
_distanceVertical++; | ||
break; | ||
case Direction.West: | ||
_distanceHorizontal--; | ||
break; | ||
case Direction.South: | ||
_distanceVertical--; | ||
break; | ||
case Direction.East: | ||
_distanceHorizontal++; | ||
break; | ||
default: | ||
throw new ArgumentOutOfRangeException(); | ||
} | ||
|
||
var point = new Point(_distanceHorizontal, _distanceVertical); | ||
|
||
if (!_crossingFound) | ||
{ | ||
if (Visited.Contains(point)) | ||
{ | ||
_firstCrossed = point; | ||
_crossingFound = true; | ||
} | ||
} | ||
|
||
Visited.Add(point); | ||
} | ||
} | ||
|
||
Console.WriteLine("Answers: "); | ||
Console.WriteLine("*: " + Visited.Last().Distance); | ||
Console.Write("**: " + _firstCrossed?.Distance); | ||
} | ||
} | ||
} |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
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
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
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,6 @@ private static void Main() | |
{ | ||
var solution = new Solution(); | ||
solution.Solve(); | ||
|
||
Console.Read(); | ||
} | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.