1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-10-29 22:17:23 +01:00

feat(challenges): add prefix-suffix

This commit is contained in:
Divlo 2021-12-02 15:25:16 +01:00
parent d14fd0b62a
commit ab09295fca
No known key found for this signature in database
GPG Key ID: 6F24DA54DA3967CF
14 changed files with 102 additions and 0 deletions

View File

@ -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.

View File

@ -0,0 +1,2 @@
Py
AlgoPy

View File

@ -0,0 +1,2 @@
false
false

View File

@ -0,0 +1,2 @@
AlgoPy
Py

View File

@ -0,0 +1,2 @@
false
true

View File

@ -0,0 +1,2 @@
same-word
same-word

View File

@ -0,0 +1,2 @@
true
true

View File

@ -0,0 +1,2 @@
unhappy
un

View File

@ -0,0 +1,2 @@
true
false

View File

@ -0,0 +1,2 @@
overload
over

View File

@ -0,0 +1,2 @@
true
false

View File

@ -0,0 +1,2 @@
simplify
ify

View File

@ -0,0 +1,2 @@
false
true