Skip to content

Commit

Permalink
Merge pull request #44 from nuoxoxo/23
Browse files Browse the repository at this point in the history
+ 2310
  • Loading branch information
nuoxoxo authored Dec 10, 2023
2 parents 0c3d592 + b01ee2b commit 838dbfc
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ import Aoc1501 from "./includes/Aoc1501";
import Aoc2301 from "./includes/Aoc2301";
import Aoc2302 from "./includes/Aoc2302";
import Aoc2303 from "./includes/Aoc2303";
import Aoc2310 from "./includes/Aoc2310";
import DadJokes from "./includes/DadJokes";
import "./styles/App.scss";

type TargetRoute = React.FC;

const routes: { [key: string]: TargetRoute } = {
// Valid Identifiers (No quotes needed)
2310: Aoc2310,
2303: Aoc2303,
2302: Aoc2302,
2301: Aoc2301,
Expand Down
63 changes: 63 additions & 0 deletions src/includes/Aoc2310.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { useState, useEffect } from "react"
import { FetchDataWithoutTrim, /*Deepcopy2DArray*/ } from "../helpers/Helpers"

const suffixes = ['in']//, 'alt']
const choice = suffixes[Math.floor(Math.random() * suffixes.length)]
const URL:string = "https://raw.githubusercontent.com/nuoxoxo/in/main/aoc/2310." + choice

var Aoc2310 = () => {

const [lines, setLines] = useState<string[]>([])
const [p1] = useState<number>(0)
const [p2] = useState<number>(0)

const handleData = async () => {

try {
const raws = await FetchDataWithoutTrim(URL)
let i = -1
while (++i < raws.length) {
raws[i] = raws[i]
.replace(/7/g, '┐')
.replace(/-/g, '─')
.replace(/L/g, '└')
.replace(/F/g, '┌')
.replace(/J/g, '┘')
.replace(/\./g, ' ')
}
setLines(raws)
} catch (error: any) {
console.error("Error fetching data: ", error)
}
}

useEffect(() => {
handleData()
}, [])

return (
<>
{lines ? (
<>

<div className="playground">
<div className="field res-field res-field-1813">
<span>--- 2023 Day 10: Pipe Maze ---</span>
<span>Part 1: {p1 ? p1 : "(empty)"} </span>
<span>Part 2: {p2 ? p2 : "(empty)"} </span>
</div>
</div>

<div className="field data-field data-field-2310">
{ lines ? lines.join("\n") : "No data available." }
</div>

</>
) : (
<p>Loading data...</p>
)}
</>
)
}

export default Aoc2310
4 changes: 4 additions & 0 deletions src/styles/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ body {
@include animation-rainbow-rotate;
}

.data-field-2310 {
font-size: 10px;
}

.data-field-1818 {
font-size: 16px;
color:$WATER-GREEN;
Expand Down

0 comments on commit 838dbfc

Please sign in to comment.