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