mirror of
				https://github.com/theoludwig/programming-challenges.git
				synced 2025-09-11 23:11:21 +02:00 
			
		
		
		
	
		
			
				
	
	
		
			23 lines
		
	
	
		
			563 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			563 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
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 () => {
 | 
						|
  const inputFile = await fs.readFile(inputPath)
 | 
						|
  const inputJSON = JSON.parse(inputFile.toString())
 | 
						|
 | 
						|
  try {
 | 
						|
    const result = solution.apply(null, inputJSON)
 | 
						|
    await fs.writeFile(outputPath, JSON.stringify(result))
 | 
						|
  } catch (error) {
 | 
						|
    console.error(error)
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
main()
 |