Skip to content

Commit

Permalink
Adding Red/Green to the colors for day 15
Browse files Browse the repository at this point in the history
  • Loading branch information
byte2pixel committed Dec 27, 2024
1 parent 87dfc0c commit a28abb1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
15 changes: 15 additions & 0 deletions 2024/Advent/UseCases/Day15/Day15Helper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Advent.UseCases.Day15;

public static class Day15Helper
{
public static string TableMarkup(string value)
{
// find the @ character and then surround it with
// [bold green]@[/] and preserve the rest of the string
return value
.Replace("[]", "[bold green][[]][/]")
.Replace("O", "[bold green]O[/]")
.Replace("#", "[bold red]#[/]")
.Replace("@", "[bold yellow]@[/]");
}
}
6 changes: 5 additions & 1 deletion 2024/Advent/UseCases/Day15/Day15Part1Solver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ private void UpdateLiveTableRows(Day15Data data, Action<int, Action>? update)
{
for (int i = 0; i < data.Data.Rows; i++)
{
_liveTable?.Rows.Update(i, 0, new Text(data.Data[i].ToString()).Centered());
_liveTable?.Rows.Update(
i,
0,
new Markup(Day15Helper.TableMarkup(data.Data[i].ToString())).Centered()
);
}
}
);
Expand Down
6 changes: 5 additions & 1 deletion 2024/Advent/UseCases/Day15/Day15Part2Solver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ private void UpdateLiveTableRows(Day15Data data, Action<int, Action>? update = n
{
for (int i = 0; i < data.Data.Rows; i++)
{
_liveTable?.Rows.Update(i, 0, new Text(data.Data[i].ToString()).Centered());
_liveTable?.Rows.Update(
i,
0,
new Markup(Day15Helper.TableMarkup(data.Data[i].ToString())).Centered()
);
}
}
);
Expand Down

0 comments on commit a28abb1

Please sign in to comment.