mirror of
https://github.com/SrIzan10/adventofcode.git
synced 2026-06-22 08:12:28 +00:00
refactor: getInput function
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
// REALLY UNCLEAN CODE BUT IT WORKS
|
||||
|
||||
import getInput from "../../util/getInput.ts"
|
||||
|
||||
const regex = /\D/g
|
||||
const array: Array<number> = []
|
||||
const file = (await (Bun.file('./src/days/1/input.txt')).text()).split('\n')
|
||||
const file = (await getInput(1)).split('\n')
|
||||
file.forEach((line) => {
|
||||
let arr = Array.from(line.replace(regex, '')).map(Number)
|
||||
console.log(`${arr} ${line}`)
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import getInput from "../../util/getInput.ts"
|
||||
|
||||
// REALLY UNCLEAN CODE BUT IT WORKS
|
||||
const regex = /\D/g
|
||||
const array: Array<number> = []
|
||||
|
||||
let file = await (Bun.file('./src/days/1/input.txt')).text()
|
||||
let file = await getInput(1)
|
||||
file = file.replaceAll("twone", "21")
|
||||
file = file.replaceAll("sevenine", "79")
|
||||
file = file.replaceAll("oneight", "18")
|
||||
|
||||
3
2023/src/util/getInput.ts
Normal file
3
2023/src/util/getInput.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export default async function getInput(day: number) {
|
||||
return await (Bun.file(`./src/days/${day}/input.txt`)).text()
|
||||
}
|
||||
Reference in New Issue
Block a user