1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-07-18 02:20:12 +02:00

build(deps): update latest

This commit is contained in:
Divlo 2022-12-30 00:55:21 +01:00
parent a04240c0ab
commit 9e751c53d9
No known key found for this signature in database
GPG Key ID: 8F9478F220CE65E9
43 changed files with 4728 additions and 1423 deletions

View File

@ -10,7 +10,7 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.{py,cs}]
[*.{py,cs,rs,java}]
indent_size = 4
[*.txt]

1
.gitignore vendored
View File

@ -13,6 +13,7 @@ obj
bin
*.out
*.exe
target
# testing
coverage

View File

@ -46,7 +46,7 @@ Gitpod will automatically setup an environment for you.
#### Prerequisites
- [Node.js](https://nodejs.org/) >= 16.0.0
- [Node.js](https://nodejs.org/) >= 18.0.0
- [npm](https://npmjs.com/) >= 8.0.0
- [Docker](https://www.docker.com/)

View File

@ -1,12 +1,13 @@
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
String line;
Scanner scanner = new Scanner(System.in);
while(scanner.hasNextLine()) {
line = scanner.nextLine();
System.out.println("Hello, " + line + "!");
public static void main(String[] args) {
String line;
Scanner scanner = new Scanner(System.in);
while (scanner.hasNextLine()) {
line = scanner.nextLine();
System.out.println("Hello, " + line + "!");
}
scanner.close();
}
}
}

View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "rust_application"
version = "1.0.0"

View File

@ -0,0 +1,6 @@
[package]
name = "rust_application"
version = "1.0.0"
edition = "2021"
[dependencies]

View File

@ -1,8 +0,0 @@
use std::io::{self, BufRead};
fn main() {
let stdin = io::stdin();
for line in stdin.lock().lines() {
println!("Hello, {}!", line.unwrap());
}
}

View 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());
}
}

View File

@ -1,22 +1,23 @@
string = input()
def isalphanum(character: str)->bool:
def is_alphanumeric(character: str) -> bool:
is_lowercase_letter = ord(character) >= ord('a') and ord(character) <= ord('z')
is_upper_letter = ord(character) >= ord('A') and ord(character) <= ord('Z')
is_digit = ord(character) >= ord('0') and ord(character) <= ord('9')
return is_upper_letter or is_lowercase_letter or is_digit
string = string.strip(' ')
string = string.strip('-')
string = string.strip(' ').strip('-')
answer = ""
current = ""
for character in string:
if character == ' ' or (character == '-' and len(current)>0):
if character == ' ' or (character == '-' and len(current) > 0):
answer += current
answer += '-'
current = ""
elif isalphanum(character):
elif is_alphanumeric(character):
current += character
answer += current

View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "rust_application"
version = "1.0.0"

View File

@ -0,0 +1,6 @@
[package]
name = "rust_application"
version = "1.0.0"
edition = "2021"
[dependencies]

View File

@ -1,25 +0,0 @@
use std::io::{self, BufRead};
fn main() {
let mut numbers: Vec<i64> = Vec::new();
let stdin = io::stdin();
for line in stdin.lock().lines().skip(1) {
let line = line.unwrap();
let number: i64 = line.trim().parse().unwrap();
numbers.push(number);
}
bubble_sort(&mut numbers);
for number in numbers {
println!("{}", number);
}
}
pub fn bubble_sort<T: Ord>(array: &mut [T]) {
for index1 in 0..array.len() {
for index2 in 0..array.len() - 1 - index1 {
if array[index2] > array[index2 + 1] {
array.swap(index2, index2 + 1);
}
}
}
}

View File

@ -0,0 +1,25 @@
use std::io::{self, BufRead};
fn main() {
let mut numbers: Vec<i64> = Vec::new();
let stdin = io::stdin();
for line in stdin.lock().lines().skip(1) {
let line = line.unwrap();
let number: i64 = line.trim().parse().unwrap();
numbers.push(number);
}
bubble_sort(&mut numbers);
for number in numbers {
println!("{}", number);
}
}
pub fn bubble_sort<T: Ord>(array: &mut [T]) {
for index1 in 0..array.len() {
for index2 in 0..array.len() - 1 - index1 {
if array[index2] > array[index2 + 1] {
array.swap(index2, index2 + 1);
}
}
}
}

View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "rust_application"
version = "1.0.0"

View File

@ -0,0 +1,6 @@
[package]
name = "rust_application"
version = "1.0.0"
edition = "2021"
[dependencies]

View File

@ -1,15 +0,0 @@
use std::io::{self, BufRead};
fn main() {
let mut numbers: Vec<i64> = Vec::new();
let stdin = io::stdin();
for line in stdin.lock().lines().skip(1) {
let line = line.unwrap();
let number: i64 = line.trim().parse().unwrap();
numbers.push(number);
}
numbers.sort();
for number in numbers {
println!("{}", number);
}
}

View File

@ -0,0 +1,15 @@
use std::io::{self, BufRead};
fn main() {
let mut numbers: Vec<i64> = Vec::new();
let stdin = io::stdin();
for line in stdin.lock().lines().skip(1) {
let line = line.unwrap();
let number: i64 = line.trim().parse().unwrap();
numbers.push(number);
}
numbers.sort();
for number in numbers {
println!("{}", number);
}
}

View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "rust_application"
version = "1.0.0"

View File

@ -0,0 +1,6 @@
[package]
name = "rust_application"
version = "1.0.0"
edition = "2021"
[dependencies]

View File

@ -1,25 +0,0 @@
use std::io::{self, BufRead};
fn main() {
let mut numbers: Vec<i64> = Vec::new();
let stdin = io::stdin();
for line in stdin.lock().lines().skip(1) {
let line = line.unwrap();
let number: i64 = line.trim().parse().unwrap();
numbers.push(number);
}
insertion_sort(&mut numbers);
for number in numbers {
println!("{}", number);
}
}
pub fn insertion_sort<T: Ord>(array: &mut [T]) {
for index in 1..array.len() {
let mut index2 = index;
while index2 > 0 && array[index2] < array[index2 - 1] {
array.swap(index2, index2 - 1);
index2 -= 1;
}
}
}

View File

@ -0,0 +1,25 @@
use std::io::{self, BufRead};
fn main() {
let mut numbers: Vec<i64> = Vec::new();
let stdin = io::stdin();
for line in stdin.lock().lines().skip(1) {
let line = line.unwrap();
let number: i64 = line.trim().parse().unwrap();
numbers.push(number);
}
insertion_sort(&mut numbers);
for number in numbers {
println!("{}", number);
}
}
pub fn insertion_sort<T: Ord>(array: &mut [T]) {
for index in 1..array.len() {
let mut index2 = index;
while index2 > 0 && array[index2] < array[index2 - 1] {
array.swap(index2, index2 - 1);
index2 -= 1;
}
}
}

View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "rust_application"
version = "1.0.0"

View File

@ -0,0 +1,6 @@
[package]
name = "rust_application"
version = "1.0.0"
edition = "2021"
[dependencies]

View File

@ -1,52 +0,0 @@
use std::io::{self, BufRead};
fn main() {
let mut numbers: Vec<i64> = Vec::new();
let stdin = io::stdin();
for line in stdin.lock().lines().skip(1) {
let line = line.unwrap();
let number: i64 = line.trim().parse().unwrap();
numbers.push(number);
}
merge_sort(&mut numbers);
for number in numbers {
println!("{}", number);
}
}
pub fn merge_sort(array: &mut Vec<i64>) {
if array.len() > 1 {
let mid = array.len() / 2;
let mut left = array[..mid].to_vec();
let mut right = array[mid..].to_vec();
merge_sort(&mut left);
merge_sort(&mut right);
merge(left, right, array);
}
}
pub fn merge(left: Vec<i64>, right: Vec<i64>, array: &mut Vec<i64>) {
let mut left_index = 0;
let mut right_index = 0;
let mut array_index = 0;
while left_index < left.len() && right_index < right.len() {
if left[left_index] <= right[right_index] {
array[array_index] = left[left_index];
left_index += 1;
} else {
array[array_index] = right[right_index];
right_index += 1;
}
array_index += 1;
}
while left_index < left.len() {
array[array_index] = left[left_index];
left_index += 1;
array_index += 1;
}
while right_index < right.len() {
array[array_index] = right[right_index];
right_index += 1;
array_index += 1;
}
}

View File

@ -0,0 +1,52 @@
use std::io::{self, BufRead};
fn main() {
let mut numbers: Vec<i64> = Vec::new();
let stdin = io::stdin();
for line in stdin.lock().lines().skip(1) {
let line = line.unwrap();
let number: i64 = line.trim().parse().unwrap();
numbers.push(number);
}
merge_sort(&mut numbers);
for number in numbers {
println!("{}", number);
}
}
pub fn merge_sort(array: &mut Vec<i64>) {
if array.len() > 1 {
let mid = array.len() / 2;
let mut left = array[..mid].to_vec();
let mut right = array[mid..].to_vec();
merge_sort(&mut left);
merge_sort(&mut right);
merge(left, right, array);
}
}
pub fn merge(left: Vec<i64>, right: Vec<i64>, array: &mut Vec<i64>) {
let mut left_index = 0;
let mut right_index = 0;
let mut array_index = 0;
while left_index < left.len() && right_index < right.len() {
if left[left_index] <= right[right_index] {
array[array_index] = left[left_index];
left_index += 1;
} else {
array[array_index] = right[right_index];
right_index += 1;
}
array_index += 1;
}
while left_index < left.len() {
array[array_index] = left[left_index];
left_index += 1;
array_index += 1;
}
while right_index < right.len() {
array[array_index] = right[right_index];
right_index += 1;
array_index += 1;
}
}

View File

@ -41,7 +41,7 @@ export class RunTestCommand extends Command {
})
public base = Option.String('--base', {
description: 'Base of the current branch (usually master)'
description: 'Base of the current branch (usually master).'
})
async execute(): Promise<number> {

5604
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@
"url": "https://github.com/Divlo/programming-challenges"
},
"engines": {
"node": ">=16.0.0",
"node": ">=18.0.0",
"npm": ">=8.0.0"
},
"main": "build/index.js",
@ -26,44 +26,44 @@
"test": "tap"
},
"dependencies": {
"chalk": "5.0.1",
"chalk": "5.2.0",
"clipanion": "3.0.1",
"date-and-time": "2.4.1",
"execa": "6.1.0",
"log-symbols": "5.1.0",
"ora": "6.1.2",
"replace-in-file": "6.3.5",
"table": "6.8.0",
"typanion": "3.12.0",
"validate-npm-package-name": "4.0.0"
"table": "6.8.1",
"typanion": "3.12.1",
"validate-npm-package-name": "5.0.0"
},
"devDependencies": {
"@commitlint/cli": "17.1.2",
"@commitlint/config-conventional": "17.1.0",
"@swc/cli": "0.1.57",
"@swc/core": "1.3.2",
"@commitlint/cli": "17.3.0",
"@commitlint/config-conventional": "17.3.0",
"@swc/cli": "0.1.59",
"@swc/core": "1.3.24",
"@types/date-and-time": "0.13.0",
"@types/mock-fs": "4.13.1",
"@types/ms": "0.7.31",
"@types/node": "18.7.18",
"@types/node": "18.11.18",
"@types/sinon": "10.0.13",
"@types/tap": "15.0.7",
"@types/validate-npm-package-name": "4.0.0",
"@typescript-eslint/eslint-plugin": "5.38.0",
"@typescript-eslint/parser": "5.38.0",
"@typescript-eslint/eslint-plugin": "5.47.1",
"@typescript-eslint/parser": "5.47.1",
"editorconfig-checker": "4.0.2",
"eslint": "8.23.1",
"eslint-config-conventions": "4.0.1",
"eslint": "8.30.0",
"eslint-config-conventions": "6.0.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-promise": "6.0.1",
"eslint-plugin-unicorn": "43.0.2",
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-unicorn": "45.0.2",
"get-stream": "6.0.1",
"markdownlint-cli2": "0.5.1",
"mock-fs": "5.1.4",
"mock-fs": "5.2.0",
"ms": "2.1.3",
"rimraf": "3.0.2",
"sinon": "14.0.0",
"tap": "16.3.0",
"typescript": "4.8.3"
"sinon": "15.0.1",
"tap": "16.3.2",
"typescript": "4.9.4"
}
}

View File

@ -1,7 +1,9 @@
FROM gcc:12.2.0
FROM gcc:12.2.0 AS builder
WORKDIR /usr/src/application
COPY ./ ./
RUN gcc ./*.c* -o solution -Wall -Wextra -Wfloat-equal -Wundef -Werror -std=c17 -pedantic -pedantic-errors -O3
WORKDIR /usr/app
COPY ./ /usr/app
RUN gcc ./*.c* -o solution.exe -Wall -Wextra -Wfloat-equal -Wundef -Werror -std=c17 -pedantic -pedantic-errors -O3
CMD ["./solution.exe"]
FROM gcr.io/distroless/cc-debian11:latest AS runner
WORKDIR /usr/src/application
COPY --from=builder /usr/src/application/solution ./
CMD ["./solution"]

View File

@ -1,7 +1,9 @@
FROM gcc:12.2.0
FROM gcc:12.2.0 AS builder
WORKDIR /usr/src/application
COPY ./ ./
RUN g++ ./*.cpp* -o solution -Wall -Wextra -Wfloat-equal -Wundef -Werror -std=c++17 -pedantic -pedantic-errors -O3
WORKDIR /usr/app
COPY ./ /usr/app
RUN g++ ./*.cpp* -o solution.exe -Wall -Wextra -Wfloat-equal -Wundef -Werror -std=c++17 -pedantic -pedantic-errors -O3
CMD ["./solution.exe"]
FROM gcr.io/distroless/cc-debian11:latest AS runner
WORKDIR /usr/src/application
COPY --from=builder /usr/src/application/solution ./
CMD ["./solution"]

View File

@ -1,7 +1,5 @@
FROM mono:6.12.0
WORKDIR /usr/src/app
WORKDIR /usr/src/application
COPY ./ ./
RUN mcs ./Solution.cs -out:Solution.exe
ENTRYPOINT ["mono", "./Solution.exe"]

View File

@ -1,6 +1,10 @@
FROM dart:2.18.1
FROM dart:2.18.6 AS builder
WORKDIR /usr/src/application
COPY ./ ./
RUN dart compile exe solution.dart -o solution
WORKDIR /usr/app
COPY ./ /usr/app
CMD ["dart", "run", "solution.dart"]
FROM scratch AS runner
WORKDIR /usr/src/application
COPY --from=builder /runtime/ /
COPY --from=builder /usr/src/application/solution ./
CMD ["./solution"]

View File

@ -1,7 +1,10 @@
FROM openjdk:19
WORKDIR /usr/app
COPY ./ /usr/app
FROM openjdk:17 AS builder
WORKDIR /usr/src/application
COPY ./ ./
RUN javac Solution.java
RUN jar cfe solution.jar Solution *.class
CMD ["java", "Solution"]
FROM gcr.io/distroless/java17-debian11:latest AS runner
WORKDIR /usr/src/application
COPY --from=builder /usr/src/application/solution.jar ./
CMD ["./solution.jar"]

View File

@ -1,6 +1,4 @@
FROM node:16.17.0
WORKDIR /usr/app
COPY ./ /usr/app
CMD ["node", "solution.js"]
FROM gcr.io/distroless/nodejs18-debian11:latest AS runner
WORKDIR /usr/src/application
COPY ./ ./
CMD ["./solution.js"]

View File

@ -1,6 +1,4 @@
FROM pypy:3.9-7
WORKDIR /usr/app
COPY ./ /usr/app
WORKDIR /usr/src/application
COPY ./ ./
CMD ["python", "solution.py"]

View File

@ -0,0 +1 @@
/target

View File

@ -1,7 +1,16 @@
FROM rust:1.64.0
FROM rust:1.66.0 AS builder
WORKDIR /usr/src/rust_application
WORKDIR /usr/app
COPY ./ /usr/app
RUN rustc -C debuginfo=0 -C opt-level=3 -C target-cpu=native solution.rs
# Cache dependencies
RUN cargo init --bin ./
COPY ./Cargo.* ./
RUN cargo build --release && rm --recursive --force ./src ./target/release/deps/rust_application*
CMD ["./solution"]
# Build application
COPY ./ ./
RUN cargo build --release
FROM gcr.io/distroless/cc-debian11:latest AS runner
WORKDIR /usr/src/rust_application
COPY --from=builder /usr/src/rust_application/target/release/rust_application ./
CMD ["./rust_application"]

View File

@ -1,7 +1,17 @@
FROM node:16.17.0
FROM node:18.12.1 AS builder-dependencies
WORKDIR /usr/src/application
COPY ./package*.json ./
RUN npm install
WORKDIR /usr/app
COPY ./ /usr/app
RUN npm install && npm run build
FROM node:18.12.1 AS builder
WORKDIR /usr/src/application
COPY --from=builder-dependencies /usr/src/application/node_modules ./node_modules
COPY ./ ./
RUN npm run build
CMD ["node", "build/solution.js"]
FROM gcr.io/distroless/nodejs18-debian11:latest AS runner
WORKDIR /usr/src/application
ENV NODE_ENV=production
COPY --from=builder /usr/src/application/package.json ./package.json
COPY --from=builder /usr/src/application/build ./build
CMD ["./build/solution.js"]

View File

@ -1,12 +1,13 @@
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
String line;
Scanner scanner = new Scanner(System.in);
while(scanner.hasNextLine()) {
line = scanner.nextLine();
System.out.println("Hello, " + line + "!");
public static void main(String[] args) {
String line;
Scanner scanner = new Scanner(System.in);
while (scanner.hasNextLine()) {
line = scanner.nextLine();
System.out.println("Hello, " + line + "!");
}
scanner.close();
}
}
}

7
templates/solution/rust/Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "rust_application"
version = "1.0.0"

View File

@ -0,0 +1,6 @@
[package]
name = "rust_application"
version = "1.0.0"
edition = "2021"
[dependencies]

View File

@ -1,8 +0,0 @@
use std::io::{self, BufRead};
fn main() {
let stdin = io::stdin();
for line in stdin.lock().lines() {
println!("Hello, {}!", line.unwrap());
}
}

View 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());
}
}