mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2025-05-18 12:02:53 +02:00
🎉 Initial commit
This commit is contained in:
17
scripts/languages-wrapper/_languages.json
Normal file
17
scripts/languages-wrapper/_languages.json
Normal file
@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"name": "Python",
|
||||
"extension": ".py",
|
||||
"launch": "python"
|
||||
},
|
||||
{
|
||||
"name": "JavaScript",
|
||||
"extension": ".js",
|
||||
"launch": "node"
|
||||
},
|
||||
{
|
||||
"name": "TypeScript",
|
||||
"extension": ".ts",
|
||||
"launch": "ts-node"
|
||||
}
|
||||
]
|
16
scripts/languages-wrapper/execute.js
Normal file
16
scripts/languages-wrapper/execute.js
Normal file
@ -0,0 +1,16 @@
|
||||
const path = require('path')
|
||||
const fs = require('fs').promises
|
||||
const solution = require('./solution')
|
||||
|
||||
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)
|
||||
|
||||
const result = solution.apply(null, inputJSON)
|
||||
await fs.writeFile(outputPath, JSON.stringify(result))
|
||||
}
|
||||
|
||||
main()
|
13
scripts/languages-wrapper/execute.py
Normal file
13
scripts/languages-wrapper/execute.py
Normal file
@ -0,0 +1,13 @@
|
||||
import os
|
||||
import json
|
||||
from solution import solution
|
||||
|
||||
current_directory = os.path.dirname(__file__)
|
||||
input_path = os.path.join(current_directory, "input.json")
|
||||
output_path = os.path.join(current_directory, "output.json")
|
||||
|
||||
with open(input_path, "r") as file_content:
|
||||
input_json = json.load(file_content)
|
||||
|
||||
with open(output_path, "w") as file_content:
|
||||
json.dump(solution(*input_json), file_content)
|
18
scripts/languages-wrapper/execute.ts
Normal file
18
scripts/languages-wrapper/execute.ts
Normal file
@ -0,0 +1,18 @@
|
||||
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())
|
||||
|
||||
const result = solution.apply(null, inputJSON)
|
||||
await fs.writeFile(outputPath, JSON.stringify(result))
|
||||
}
|
||||
|
||||
main()
|
5
scripts/languages-wrapper/templates/solution.js
Normal file
5
scripts/languages-wrapper/templates/solution.js
Normal file
@ -0,0 +1,5 @@
|
||||
function solution () {
|
||||
|
||||
}
|
||||
|
||||
module.exports = solution
|
2
scripts/languages-wrapper/templates/solution.py
Normal file
2
scripts/languages-wrapper/templates/solution.py
Normal file
@ -0,0 +1,2 @@
|
||||
def solution():
|
||||
pass
|
5
scripts/languages-wrapper/templates/solution.ts
Normal file
5
scripts/languages-wrapper/templates/solution.ts
Normal file
@ -0,0 +1,5 @@
|
||||
function solution () {
|
||||
|
||||
}
|
||||
|
||||
export default solution
|
Reference in New Issue
Block a user