Skip to content

Commit

Permalink
Update Aoc2223.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
nuoxoxo authored Sep 20, 2023
1 parent 31433f1 commit ea937dc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/includes/Aoc2223.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { FetchData, LenNStrsFromLine } from "../helpers/Helpers"
const URL: string = "https://raw.githubusercontent.com/nuoxoxo/in/main/aoc/2223.1"

var Aoc2223 = () => {

const [lines, setLines] = useState<string[]>([])
const [gridPart1, setGridPart1] = useState<string[][]>([])
const [p1, setP1] = useState<number>(0)
const [set1, setSet1] = useState<Set<number[]>>(new Set<number[]>())
const [p2 /*, setP2*/] = useState<number>(0)

const handleData = async () => {

try {
const raws = await FetchData(URL)
setLines(raws)
Expand All @@ -20,14 +22,17 @@ var Aoc2223 = () => {
}

const prepare_state_for_printing = (state:Set<number[]>): string[] | undefined => {

if (!state.size)
return
const stateArray = [ ... state]
const min_x = stateArray.length > 0 ? Math.min(...stateArray.map(x => x[0])) : undefined
const min_y = stateArray.length > 0 ? Math.min(...stateArray.map(x => x[1])) : undefined
const max_x = stateArray.length > 0 ? Math.max(...stateArray.map(x => x[0])) : undefined
const max_y = stateArray.length > 0 ? Math.max(...stateArray.map(x => x[1])) : undefined

console.log(min_x, min_y, max_x, max_y)

let G:string[] = []
let x = min_x! - 1
while (++x < max_x! + 1) {
Expand Down

0 comments on commit ea937dc

Please sign in to comment.