2020-07-05 15:48:51 +02:00
|
|
|
import path from 'path'
|
|
|
|
import * as fsWithCallbacks from 'fs'
|
|
|
|
// @ts-ignore
|
|
|
|
import solution from './solution'
|
|
|
|
|
|
|
|
const fs = fsWithCallbacks.promises
|
|
|
|
const inputPath = path.join(__dirname, 'input.json')
|
|
|
|
const outputPath = path.join(__dirname, 'output.json')
|
|
|
|
|
|
|
|
const main = async () => {
|
2021-02-18 19:40:44 +01:00
|
|
|
const inputFile = await fs.readFile(inputPath, { encoding: 'utf-8' })
|
2020-07-05 15:48:51 +02:00
|
|
|
const inputJSON = JSON.parse(inputFile.toString())
|
|
|
|
|
2020-11-15 12:37:54 +01:00
|
|
|
try {
|
|
|
|
const result = solution.apply(null, inputJSON)
|
2021-02-18 19:40:44 +01:00
|
|
|
await fs.writeFile(outputPath, JSON.stringify(result), { encoding: 'utf-8' })
|
2020-11-15 12:37:54 +01:00
|
|
|
} catch (error) {
|
|
|
|
console.error(error)
|
|
|
|
}
|
2020-07-05 15:48:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
main()
|