seed: curriculum content
This commit is contained in:
43
1.solar-system/3.strings/05.the-mirror/index.md
Normal file
43
1.solar-system/3.strings/05.the-mirror/index.md
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
type: challenge
|
||||
title: "The Mirror"
|
||||
xp: 75
|
||||
duration: 30
|
||||
difficulty: 3
|
||||
---
|
||||
|
||||
# The Mirror
|
||||
|
||||
> **[INCOMING — Mission Control, Earth]**
|
||||
>
|
||||
> Cadet, a *palindrome* reads the same forwards and backwards.
|
||||
> `racecar`. `level`. `madam`.
|
||||
>
|
||||
> A reverse-slice flips a string in one move:
|
||||
>
|
||||
> ```python
|
||||
> "Hello"[::-1] # "olleH"
|
||||
> ```
|
||||
>
|
||||
> A string is a palindrome when it equals its reverse. The `==`
|
||||
> operator returns `True` or `False` directly.
|
||||
>
|
||||
> Implement `mirror(s)` that returns a dict with three keys:
|
||||
>
|
||||
> - `original` — the input
|
||||
> - `reversed` — the input reversed
|
||||
> - `palindrome` — `True` if equal to its reverse
|
||||
>
|
||||
> Match case exactly — `racecar` and `RaceCar` are different inputs.
|
||||
>
|
||||
> [END TRANSMISSION]
|
||||
|
||||
## Your Task
|
||||
|
||||
In `starter/starter.py`, build the dict using `[::-1]` and `==`.
|
||||
|
||||
## Objectives
|
||||
|
||||
- `mirror("racecar")["palindrome"]` is `True`
|
||||
- `mirror("hello")["palindrome"]` is `False`
|
||||
- All three keys correct for any input string
|
||||
Reference in New Issue
Block a user