From ab09295fcab2a91c101f283be0cc42274c9251eb Mon Sep 17 00:00:00 2001 From: Divlo Date: Thu, 2 Dec 2021 15:25:16 +0100 Subject: [PATCH] feat(challenges): add `prefix-suffix` --- challenges/prefix-suffix/README.md | 78 +++++++++++++++++++++ challenges/prefix-suffix/solutions/.gitkeep | 0 challenges/prefix-suffix/test/1/input.txt | 2 + challenges/prefix-suffix/test/1/output.txt | 2 + challenges/prefix-suffix/test/2/input.txt | 2 + challenges/prefix-suffix/test/2/output.txt | 2 + challenges/prefix-suffix/test/3/input.txt | 2 + challenges/prefix-suffix/test/3/output.txt | 2 + challenges/prefix-suffix/test/4/input.txt | 2 + challenges/prefix-suffix/test/4/output.txt | 2 + challenges/prefix-suffix/test/5/input.txt | 2 + challenges/prefix-suffix/test/5/output.txt | 2 + challenges/prefix-suffix/test/6/input.txt | 2 + challenges/prefix-suffix/test/6/output.txt | 2 + 14 files changed, 102 insertions(+) create mode 100644 challenges/prefix-suffix/README.md create mode 100644 challenges/prefix-suffix/solutions/.gitkeep create mode 100644 challenges/prefix-suffix/test/1/input.txt create mode 100644 challenges/prefix-suffix/test/1/output.txt create mode 100644 challenges/prefix-suffix/test/2/input.txt create mode 100644 challenges/prefix-suffix/test/2/output.txt create mode 100644 challenges/prefix-suffix/test/3/input.txt create mode 100644 challenges/prefix-suffix/test/3/output.txt create mode 100644 challenges/prefix-suffix/test/4/input.txt create mode 100644 challenges/prefix-suffix/test/4/output.txt create mode 100644 challenges/prefix-suffix/test/5/input.txt create mode 100644 challenges/prefix-suffix/test/5/output.txt create mode 100644 challenges/prefix-suffix/test/6/input.txt create mode 100644 challenges/prefix-suffix/test/6/output.txt diff --git a/challenges/prefix-suffix/README.md b/challenges/prefix-suffix/README.md new file mode 100644 index 0000000..4a6ab91 --- /dev/null +++ b/challenges/prefix-suffix/README.md @@ -0,0 +1,78 @@ +# prefix-suffix + +Created by [@Divlo](https://github.com/Divlo) on 2 December 2021. + +## Instructions + +A prefix is an affix which is placed before the stem of a word. Adding it to the beginning of one word changes it into another word. For example, when the prefix un- is added to the word happy, it creates the word unhappy. + +A suffix is an affix which is placed after the stem of a word. Common examples are case endings, which indicate the grammatical case of nouns, adjectives, and verb endings, which form the conjugation of verbs. Suffixes can carry grammatical information or lexical information. + +Write a programs that takes 2 strings ("words") and prints if one is a prefix/suffix of the other. + +### Input + +- **Line 1:** The word to be checked +- **Line 2:** The potential prefix/suffix + +### Output + +- **Line 1:** `true` if the second word is a **prefix** of the first, `false` otherwise +- **Line 1:** `true` if the second word is a **suffix** of the first, `false` otherwise + +## Source + +- [Wikipedia - Prefix](https://en.wikipedia.org/wiki/Prefix) +- [Wikipedia - Suffix](https://en.wikipedia.org/wiki/Suffix) + +## Examples + +### Example 1 + +#### Input + +```txt +Py +AlgoPy +``` + +#### Output + +```txt +false +false +``` + +### Example 2 + +#### Input + +```txt +AlgoPy +Py +``` + +#### Output + +```txt +false +true +``` + +### Example 3 + +#### Input + +```txt +same-word +same-word +``` + +#### Output + +```txt +true +true +``` + +See the `test` folder for examples of input/output. diff --git a/challenges/prefix-suffix/solutions/.gitkeep b/challenges/prefix-suffix/solutions/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/challenges/prefix-suffix/test/1/input.txt b/challenges/prefix-suffix/test/1/input.txt new file mode 100644 index 0000000..fd1a161 --- /dev/null +++ b/challenges/prefix-suffix/test/1/input.txt @@ -0,0 +1,2 @@ +Py +AlgoPy \ No newline at end of file diff --git a/challenges/prefix-suffix/test/1/output.txt b/challenges/prefix-suffix/test/1/output.txt new file mode 100644 index 0000000..1272bc6 --- /dev/null +++ b/challenges/prefix-suffix/test/1/output.txt @@ -0,0 +1,2 @@ +false +false \ No newline at end of file diff --git a/challenges/prefix-suffix/test/2/input.txt b/challenges/prefix-suffix/test/2/input.txt new file mode 100644 index 0000000..60557fa --- /dev/null +++ b/challenges/prefix-suffix/test/2/input.txt @@ -0,0 +1,2 @@ +AlgoPy +Py \ No newline at end of file diff --git a/challenges/prefix-suffix/test/2/output.txt b/challenges/prefix-suffix/test/2/output.txt new file mode 100644 index 0000000..5b3ac40 --- /dev/null +++ b/challenges/prefix-suffix/test/2/output.txt @@ -0,0 +1,2 @@ +false +true \ No newline at end of file diff --git a/challenges/prefix-suffix/test/3/input.txt b/challenges/prefix-suffix/test/3/input.txt new file mode 100644 index 0000000..ea34fea --- /dev/null +++ b/challenges/prefix-suffix/test/3/input.txt @@ -0,0 +1,2 @@ +same-word +same-word \ No newline at end of file diff --git a/challenges/prefix-suffix/test/3/output.txt b/challenges/prefix-suffix/test/3/output.txt new file mode 100644 index 0000000..0be5d98 --- /dev/null +++ b/challenges/prefix-suffix/test/3/output.txt @@ -0,0 +1,2 @@ +true +true \ No newline at end of file diff --git a/challenges/prefix-suffix/test/4/input.txt b/challenges/prefix-suffix/test/4/input.txt new file mode 100644 index 0000000..a1ec48c --- /dev/null +++ b/challenges/prefix-suffix/test/4/input.txt @@ -0,0 +1,2 @@ +unhappy +un \ No newline at end of file diff --git a/challenges/prefix-suffix/test/4/output.txt b/challenges/prefix-suffix/test/4/output.txt new file mode 100644 index 0000000..d252328 --- /dev/null +++ b/challenges/prefix-suffix/test/4/output.txt @@ -0,0 +1,2 @@ +true +false \ No newline at end of file diff --git a/challenges/prefix-suffix/test/5/input.txt b/challenges/prefix-suffix/test/5/input.txt new file mode 100644 index 0000000..327e967 --- /dev/null +++ b/challenges/prefix-suffix/test/5/input.txt @@ -0,0 +1,2 @@ +overload +over \ No newline at end of file diff --git a/challenges/prefix-suffix/test/5/output.txt b/challenges/prefix-suffix/test/5/output.txt new file mode 100644 index 0000000..d252328 --- /dev/null +++ b/challenges/prefix-suffix/test/5/output.txt @@ -0,0 +1,2 @@ +true +false \ No newline at end of file diff --git a/challenges/prefix-suffix/test/6/input.txt b/challenges/prefix-suffix/test/6/input.txt new file mode 100644 index 0000000..0309dd4 --- /dev/null +++ b/challenges/prefix-suffix/test/6/input.txt @@ -0,0 +1,2 @@ +simplify +ify \ No newline at end of file diff --git a/challenges/prefix-suffix/test/6/output.txt b/challenges/prefix-suffix/test/6/output.txt new file mode 100644 index 0000000..5b3ac40 --- /dev/null +++ b/challenges/prefix-suffix/test/6/output.txt @@ -0,0 +1,2 @@ +false +true \ No newline at end of file