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:
3
challenges/hello-world/solutions/c/function/README.md
Normal file
3
challenges/hello-world/solutions/c/function/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# hello-world/c/function
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 6 June 2021.
|
10
challenges/hello-world/solutions/c/function/solution.c
Normal file
10
challenges/hello-world/solutions/c/function/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;
|
||||
}
|
3
challenges/hello-world/solutions/cpp/function/README.md
Normal file
3
challenges/hello-world/solutions/cpp/function/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# hello-world/cpp/function
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 7 June 2021.
|
@ -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;
|
||||
}
|
3
challenges/hello-world/solutions/dart/function/README.md
Normal file
3
challenges/hello-world/solutions/dart/function/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# hello-world/dart/function
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 6 June 2021.
|
11
challenges/hello-world/solutions/dart/function/solution.dart
Normal file
11
challenges/hello-world/solutions/dart/function/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!');
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
# javascript-hello - hello-world
|
||||
|
||||
Programming language : JavaScript
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 5 July 2020.
|
@ -1,5 +0,0 @@
|
||||
function solution (arg) {
|
||||
return 'Hello ' + arg + '!'
|
||||
}
|
||||
|
||||
module.exports = solution
|
@ -0,0 +1,3 @@
|
||||
# hello-world/javascript/function
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 6 June 2021.
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
@ -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]}!`)
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
# python-hello - hello-world
|
||||
|
||||
Programming language : Python
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 5 July 2020.
|
@ -1,2 +0,0 @@
|
||||
def solution(arg):
|
||||
return 'Hello ' + arg + '!'
|
@ -0,0 +1,3 @@
|
||||
# hello-world/python/function
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 6 June 2021.
|
@ -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]}!')
|
3
challenges/hello-world/solutions/rust/function/README.md
Normal file
3
challenges/hello-world/solutions/rust/function/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# hello-world/rust/function
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 7 June 2021.
|
@ -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());
|
||||
}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
# typescript-hello - hello-world
|
||||
|
||||
Programming language : TypeScript
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 5 July 2020.
|
@ -1,5 +0,0 @@
|
||||
function solution (arg: string) {
|
||||
return 'Hello ' + arg + '!'
|
||||
}
|
||||
|
||||
export default solution
|
@ -0,0 +1,3 @@
|
||||
# hello-world/typescript/function
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 6 June 2021.
|
@ -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