Skip to content

Commit 51ed866

Browse files
10-2023 part 1 cleanup
1 parent ef35aaa commit 51ed866

File tree

2 files changed

+1
-190
lines changed

2 files changed

+1
-190
lines changed

2023/Day10/Solution.cs

Lines changed: 0 additions & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Collections.Immutable;
43
using System.ComponentModel;
54
using System.Linq;
6-
using System.Text.RegularExpressions;
7-
using System.Text;
8-
using AdventOfCode.Y2018.Day13;
95

106
namespace AdventOfCode.Y2023.Day10;
117

@@ -28,74 +24,31 @@ public object PartOne(string input)
2824
if (pipesMap.Last().Value == Direction.Right)
2925
{
3026
currentPoint = (pipesMap.Last().Key.Item1, pipesMap.Last().Key.Item2 + 1);
31-
Console.WriteLine("We went right\n" + lines[currentPoint.Item1][currentPoint.Item2]);
3227
newDirection = GetNewDirection(Direction.Right, lines[currentPoint.Item1][currentPoint.Item2]);
3328
}
3429
else if (pipesMap.Last().Value == Direction.Left)
3530
{
3631
currentPoint = (pipesMap.Last().Key.Item1, pipesMap.Last().Key.Item2 - 1);
37-
Console.WriteLine("We went left\n" + lines[currentPoint.Item1][currentPoint.Item2]);
3832
newDirection = GetNewDirection(Direction.Left, lines[currentPoint.Item1][currentPoint.Item2]);
3933
}
4034
else if (pipesMap.Last().Value == Direction.Up)
4135
{
4236
currentPoint = (pipesMap.Last().Key.Item1 - 1, pipesMap.Last().Key.Item2);
43-
Console.WriteLine("We went up\n" + lines[currentPoint.Item1][currentPoint.Item2]);
4437
newDirection = GetNewDirection(Direction.Up, lines[currentPoint.Item1][currentPoint.Item2]);
4538
}
4639
else if (pipesMap.Last().Value == Direction.Down)
4740
{
4841
currentPoint = (pipesMap.Last().Key.Item1 + 1, pipesMap.Last().Key.Item2);
49-
Console.WriteLine("We went Down\n" + lines[currentPoint.Item1][currentPoint.Item2]);
5042
newDirection = GetNewDirection(Direction.Down, lines[currentPoint.Item1][currentPoint.Item2]);
5143
}
5244

5345
if (newDirection == Direction.End)
5446
{
5547
// We went back to the previous point
56-
Console.WriteLine("We went back to the starting point");
5748
break;
5849
}
5950

60-
// Just to be sure
61-
var actualChar = lines[currentPoint.Item1][currentPoint.Item2];
62-
Console.WriteLine("==> " + actualChar);
63-
switch (pipesMap.Last().Value)
64-
{
65-
case Direction.Down:
66-
{
67-
var down = new[] { '|', 'L', 'J' };
68-
if (!down.Contains(actualChar))
69-
throw new InvalidOperationException("We went down but there is no correct pipe");
70-
break;
71-
}
72-
case Direction.Up:
73-
{
74-
var up = new[] { '|', '7', 'F' };
75-
if (!up.Contains(actualChar))
76-
throw new InvalidOperationException("We went up but there is no correct pipe");
77-
break;
78-
}
79-
case Direction.Left:
80-
{
81-
var left = new[] { '-', 'F', 'L' };
82-
if (!left.Contains(actualChar))
83-
throw new InvalidOperationException("We went left but there is no correct pipe");
84-
break;
85-
}
86-
case Direction.Right:
87-
{
88-
var right = new[] { '-', 'J', '7' };
89-
if (!right.Contains(actualChar))
90-
throw new InvalidOperationException("We went right but there is no correct pipe");
91-
break;
92-
}
93-
}
94-
9551
pipesMap.Add(currentPoint, newDirection);
96-
97-
// Display pipesMap.Last() data
98-
Console.WriteLine($"Step {pipesMap.Count} Key: {string.Join(", ", pipesMap.Last().Key)}, Value: {pipesMap.Last().Value}");
9952
}
10053

10154
return (pipesMap.Count) / 2;
@@ -117,7 +70,6 @@ private static string[] ParseLines(string input) =>
11770
{
11871
if (lines[i][j] == 'S')
11972
{
120-
Console.WriteLine($"We found the starting point ({i}, {j})");
12173
// Hardcoded starting direction
12274
return new KeyValuePair<(int, int), Direction>((i, j), Direction.Right);
12375
}
@@ -127,48 +79,6 @@ private static string[] ParseLines(string input) =>
12779
return new KeyValuePair<(int, int), Direction>();
12880
}
12981

130-
// private static Direction GetStartingDirection(IReadOnlyList<string> lines, int lineIndex, int pipeIndex)
131-
// {
132-
// var newDirections = new List<Direction>();
133-
// if (lineIndex > 0)
134-
// {
135-
// var newDirection = GetNewDirection(Direction.Up, lines[lineIndex - 1][pipeIndex]);
136-
// if (newDirection != Direction.Down)
137-
// {
138-
// newDirections.Add(newDirection);
139-
// }
140-
// }
141-
//
142-
// if (lineIndex < lines.Count - 1)
143-
// {
144-
// var newDirection = GetNewDirection(Direction.Down, lines[lineIndex + 1][pipeIndex]);
145-
// if (newDirection != Direction.Up)
146-
// {
147-
// newDirections.Add(newDirection);
148-
// }
149-
// }
150-
//
151-
// if (pipeIndex > 0)
152-
// {
153-
// var newDirection = GetNewDirection(Direction.Left, lines[lineIndex][pipeIndex - 1]);
154-
// if (newDirection != Direction.Right)
155-
// {
156-
// newDirections.Add(newDirection);
157-
// }
158-
// }
159-
//
160-
// if (pipeIndex < lines[lineIndex].Length - 1)
161-
// {
162-
// var newDirection = GetNewDirection(Direction.Right, lines[lineIndex][pipeIndex + 1]);
163-
// if (newDirection != Direction.Left)
164-
// {
165-
// newDirections.Add(newDirection);
166-
// }
167-
// }
168-
//
169-
// return newDirections.Last();
170-
// }
171-
17282
private static Direction GetNewDirection(Direction previousDirection, char pipe)
17383
{
17484
if (pipe == 'S')
@@ -218,103 +128,3 @@ internal enum Direction
218128
Right,
219129
End
220130
}
221-
222-
class Position
223-
{
224-
public int x;
225-
public int y;
226-
227-
public Position(int x, int y)
228-
{
229-
this.x = x;
230-
this.y = y;
231-
}
232-
}
233-
234-
class Pipe
235-
{
236-
public char symbol;
237-
public int x;
238-
public int y;
239-
240-
public bool north;
241-
public bool east;
242-
public bool south;
243-
public bool west;
244-
245-
public bool scheduleToRemove;
246-
247-
public Pipe(char symbol, int x, int y)
248-
{
249-
this.symbol = symbol;
250-
this.x = x;
251-
this.y = y;
252-
SetConnections();
253-
}
254-
255-
public void ScheduleToRemove()
256-
{
257-
scheduleToRemove = true;
258-
}
259-
260-
public void CleanUp()
261-
{
262-
if (scheduleToRemove)
263-
{
264-
symbol = '.';
265-
north = false;
266-
east = false;
267-
south = false;
268-
west = false;
269-
}
270-
}
271-
272-
private void SetConnections()
273-
{
274-
switch (symbol)
275-
{
276-
case 'S':
277-
north = true;
278-
east = true;
279-
south = true;
280-
west = true;
281-
break;
282-
case 'F':
283-
north = false;
284-
east = true;
285-
south = true;
286-
west = false;
287-
break;
288-
case '-':
289-
north = false;
290-
east = true;
291-
south = false;
292-
west = true;
293-
break;
294-
case '7':
295-
north = false;
296-
east = false;
297-
south = true;
298-
west = true;
299-
break;
300-
case '|':
301-
north = true;
302-
east = false;
303-
south = true;
304-
west = false;
305-
break;
306-
case 'J':
307-
north = true;
308-
east = false;
309-
south = false;
310-
west = true;
311-
break;
312-
case 'L':
313-
north = true;
314-
east = true;
315-
south = false;
316-
west = false;
317-
break;
318-
}
319-
}
320-
}

2023/Day10/input.refout

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6875

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy