mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2025-05-18 12:02:53 +02:00
feat: rewrite programming-challenges CLI (#3)
This commit is contained in:
11
templates/challenge/README.md
Normal file
11
templates/challenge/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
# {{ name }}
|
||||
|
||||
{{ description }}
|
||||
|
||||
## Instructions
|
||||
|
||||
Description of the challenge...
|
||||
|
||||
## Examples
|
||||
|
||||
See the `test` folder for examples of input/output.
|
0
templates/challenge/solutions/.gitkeep
Normal file
0
templates/challenge/solutions/.gitkeep
Normal file
1
templates/challenge/test/1/input.txt
Normal file
1
templates/challenge/test/1/input.txt
Normal file
@ -0,0 +1 @@
|
||||
world
|
1
templates/challenge/test/1/output.txt
Normal file
1
templates/challenge/test/1/output.txt
Normal file
@ -0,0 +1 @@
|
||||
Hello, world!
|
4
templates/docker/c/Dockerfile
Normal file
4
templates/docker/c/Dockerfile
Normal file
@ -0,0 +1,4 @@
|
||||
FROM gcc:11.1.0
|
||||
COPY ./ ./
|
||||
RUN gcc solution.c --output=solution
|
||||
CMD ["./solution"]
|
4
templates/docker/cpp/Dockerfile
Normal file
4
templates/docker/cpp/Dockerfile
Normal file
@ -0,0 +1,4 @@
|
||||
FROM gcc:11.1.0
|
||||
COPY ./ ./
|
||||
RUN g++ solution.cpp --output=solution
|
||||
CMD ["./solution"]
|
3
templates/docker/dart/Dockerfile
Normal file
3
templates/docker/dart/Dockerfile
Normal file
@ -0,0 +1,3 @@
|
||||
FROM dart:2.13.1
|
||||
COPY ./ ./
|
||||
CMD ["dart", "run", "solution.dart"]
|
3
templates/docker/javascript/Dockerfile
Normal file
3
templates/docker/javascript/Dockerfile
Normal file
@ -0,0 +1,3 @@
|
||||
FROM node:16.3.0
|
||||
COPY ./ ./
|
||||
CMD ["node", "solution.js"]
|
3
templates/docker/python/Dockerfile
Normal file
3
templates/docker/python/Dockerfile
Normal file
@ -0,0 +1,3 @@
|
||||
FROM python:3.9.5
|
||||
COPY ./ ./
|
||||
CMD ["python", "solution.py"]
|
4
templates/docker/rust/Dockerfile
Normal file
4
templates/docker/rust/Dockerfile
Normal file
@ -0,0 +1,4 @@
|
||||
FROM rust:1.52.1
|
||||
COPY ./ ./
|
||||
RUN rustc solution.rs
|
||||
CMD ["./solution"]
|
4
templates/docker/typescript/Dockerfile
Normal file
4
templates/docker/typescript/Dockerfile
Normal file
@ -0,0 +1,4 @@
|
||||
FROM node:16.3.0
|
||||
RUN npm install --global ts-node typescript @types/node
|
||||
COPY ./ ./
|
||||
CMD ["ts-node", "solution.ts"]
|
3
templates/solution/base/README.md
Normal file
3
templates/solution/base/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# {{ name }}
|
||||
|
||||
{{ description }}
|
10
templates/solution/c/solution.c
Normal file
10
templates/solution/c/solution.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main() {
|
||||
char input[1024];
|
||||
while (scanf("%s", &input) != EOF) {
|
||||
printf("Hello, %s!", input);
|
||||
}
|
||||
return 0;
|
||||
}
|
9
templates/solution/cpp/solution.cpp
Normal file
9
templates/solution/cpp/solution.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main() {
|
||||
for (std::string line; std::getline(std::cin, line);) {
|
||||
std::cout << "Hello, " + line + "!" << std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
11
templates/solution/dart/solution.dart
Normal file
11
templates/solution/dart/solution.dart
Normal file
@ -0,0 +1,11 @@
|
||||
import 'dart:io';
|
||||
|
||||
String readLineSync() {
|
||||
String? string = stdin.readLineSync();
|
||||
return string == null ? '' : string;
|
||||
}
|
||||
|
||||
void main() {
|
||||
String input = readLineSync();
|
||||
print('Hello, $input!');
|
||||
}
|
3
templates/solution/javascript/package.json
Normal file
3
templates/solution/javascript/package.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
15
templates/solution/javascript/solution.js
Normal file
15
templates/solution/javascript/solution.js
Normal file
@ -0,0 +1,15 @@
|
||||
import readline from 'readline'
|
||||
|
||||
const input = []
|
||||
const readlineInterface = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
})
|
||||
readlineInterface.on('line', (value) => {
|
||||
input.push(value)
|
||||
})
|
||||
readlineInterface.on('close', solution)
|
||||
|
||||
function solution() {
|
||||
console.log(`Hello, ${input[0]}!`)
|
||||
}
|
8
templates/solution/python/solution.py
Normal file
8
templates/solution/python/solution.py
Normal file
@ -0,0 +1,8 @@
|
||||
from typing import List
|
||||
import sys
|
||||
|
||||
input_values: List[str] = []
|
||||
for value in sys.stdin:
|
||||
input_values.append(value.rstrip('\n'))
|
||||
|
||||
print(f'Hello, {input_values[0]}!')
|
8
templates/solution/rust/solution.rs
Normal file
8
templates/solution/rust/solution.rs
Normal file
@ -0,0 +1,8 @@
|
||||
use std::io::{self, BufRead};
|
||||
|
||||
fn main() {
|
||||
let stdin = io::stdin();
|
||||
for line in stdin.lock().lines() {
|
||||
println!("Hello, {}!", line.unwrap());
|
||||
}
|
||||
}
|
15
templates/solution/typescript/solution.ts
Normal file
15
templates/solution/typescript/solution.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import readline from 'readline'
|
||||
|
||||
const input: string[] = []
|
||||
const readlineInterface = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
})
|
||||
readlineInterface.on('line', (value) => {
|
||||
input.push(value)
|
||||
})
|
||||
readlineInterface.on('close', solution)
|
||||
|
||||
function solution(): void {
|
||||
console.log(`Hello, ${input[0]}!`)
|
||||
}
|
Reference in New Issue
Block a user