From 47de82f417921ce8024ab435daa2c7829e33dad6 Mon Sep 17 00:00:00 2001 From: Divlo Date: Sun, 21 May 2023 12:02:02 +0200 Subject: [PATCH] feat(challenges): add `left-pad` --- challenges/left-pad/README.md | 35 ++++++++++++++++++++++++++ challenges/left-pad/solutions/.gitkeep | 0 challenges/left-pad/test/1/input.txt | 3 +++ challenges/left-pad/test/1/output.txt | 1 + challenges/left-pad/test/2/input.txt | 3 +++ challenges/left-pad/test/2/output.txt | 1 + challenges/left-pad/test/3/input.txt | 3 +++ challenges/left-pad/test/3/output.txt | 1 + challenges/left-pad/test/4/input.txt | 3 +++ challenges/left-pad/test/4/output.txt | 1 + challenges/left-pad/test/5/input.txt | 3 +++ challenges/left-pad/test/5/output.txt | 1 + challenges/left-pad/test/6/input.txt | 3 +++ challenges/left-pad/test/6/output.txt | 1 + 14 files changed, 59 insertions(+) create mode 100644 challenges/left-pad/README.md create mode 100644 challenges/left-pad/solutions/.gitkeep create mode 100644 challenges/left-pad/test/1/input.txt create mode 100644 challenges/left-pad/test/1/output.txt create mode 100644 challenges/left-pad/test/2/input.txt create mode 100644 challenges/left-pad/test/2/output.txt create mode 100644 challenges/left-pad/test/3/input.txt create mode 100644 challenges/left-pad/test/3/output.txt create mode 100644 challenges/left-pad/test/4/input.txt create mode 100644 challenges/left-pad/test/4/output.txt create mode 100644 challenges/left-pad/test/5/input.txt create mode 100644 challenges/left-pad/test/5/output.txt create mode 100644 challenges/left-pad/test/6/input.txt create mode 100644 challenges/left-pad/test/6/output.txt diff --git a/challenges/left-pad/README.md b/challenges/left-pad/README.md new file mode 100644 index 0000000..105bb45 --- /dev/null +++ b/challenges/left-pad/README.md @@ -0,0 +1,35 @@ +# left-pad + +Created by [@Divlo](https://github.com/Divlo) on 21 May 2023. + +## Instructions + +Create a function that pads the current string with another string (multiple times, if needed) until the resulting string reaches the given length. The padding is applied from the start (left) of the current string. + +Inspired from [left-pad (JavaScript npm package)](https://www.npmjs.com/package/left-pad). + +### Input + +- **Line 1:** The current string +- **Line 2:** The length of the resulting string +- **Line 3:** The string to pad the current string with + +## Examples + +See the `test` folder for examples of input/output. + +### Example 1 + +#### Input + +```txt +foo +12 +- +``` + +#### Output + +```txt +---------foo +``` diff --git a/challenges/left-pad/solutions/.gitkeep b/challenges/left-pad/solutions/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/challenges/left-pad/test/1/input.txt b/challenges/left-pad/test/1/input.txt new file mode 100644 index 0000000..5d11e67 --- /dev/null +++ b/challenges/left-pad/test/1/input.txt @@ -0,0 +1,3 @@ +foo +12 +- \ No newline at end of file diff --git a/challenges/left-pad/test/1/output.txt b/challenges/left-pad/test/1/output.txt new file mode 100644 index 0000000..225ec5d --- /dev/null +++ b/challenges/left-pad/test/1/output.txt @@ -0,0 +1 @@ +---------foo \ No newline at end of file diff --git a/challenges/left-pad/test/2/input.txt b/challenges/left-pad/test/2/input.txt new file mode 100644 index 0000000..23b9955 --- /dev/null +++ b/challenges/left-pad/test/2/input.txt @@ -0,0 +1,3 @@ +foobar +5 + \ No newline at end of file diff --git a/challenges/left-pad/test/2/output.txt b/challenges/left-pad/test/2/output.txt new file mode 100644 index 0000000..f6ea049 --- /dev/null +++ b/challenges/left-pad/test/2/output.txt @@ -0,0 +1 @@ +foobar \ No newline at end of file diff --git a/challenges/left-pad/test/3/input.txt b/challenges/left-pad/test/3/input.txt new file mode 100644 index 0000000..39bc35d --- /dev/null +++ b/challenges/left-pad/test/3/input.txt @@ -0,0 +1,3 @@ +foo +4 + \ No newline at end of file diff --git a/challenges/left-pad/test/3/output.txt b/challenges/left-pad/test/3/output.txt new file mode 100644 index 0000000..c4e1d01 --- /dev/null +++ b/challenges/left-pad/test/3/output.txt @@ -0,0 +1 @@ + foo \ No newline at end of file diff --git a/challenges/left-pad/test/4/input.txt b/challenges/left-pad/test/4/input.txt new file mode 100644 index 0000000..f792d21 --- /dev/null +++ b/challenges/left-pad/test/4/input.txt @@ -0,0 +1,3 @@ +foo +5 + \ No newline at end of file diff --git a/challenges/left-pad/test/4/output.txt b/challenges/left-pad/test/4/output.txt new file mode 100644 index 0000000..2fcdedb --- /dev/null +++ b/challenges/left-pad/test/4/output.txt @@ -0,0 +1 @@ + foo \ No newline at end of file diff --git a/challenges/left-pad/test/5/input.txt b/challenges/left-pad/test/5/input.txt new file mode 100644 index 0000000..7492ad1 --- /dev/null +++ b/challenges/left-pad/test/5/input.txt @@ -0,0 +1,3 @@ +foobar +13 + \ No newline at end of file diff --git a/challenges/left-pad/test/5/output.txt b/challenges/left-pad/test/5/output.txt new file mode 100644 index 0000000..fddcaa4 --- /dev/null +++ b/challenges/left-pad/test/5/output.txt @@ -0,0 +1 @@ + foobar \ No newline at end of file diff --git a/challenges/left-pad/test/6/input.txt b/challenges/left-pad/test/6/input.txt new file mode 100644 index 0000000..f42c81a --- /dev/null +++ b/challenges/left-pad/test/6/input.txt @@ -0,0 +1,3 @@ +foobar +6 + \ No newline at end of file diff --git a/challenges/left-pad/test/6/output.txt b/challenges/left-pad/test/6/output.txt new file mode 100644 index 0000000..f6ea049 --- /dev/null +++ b/challenges/left-pad/test/6/output.txt @@ -0,0 +1 @@ +foobar \ No newline at end of file