forked from exercism/php
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07a1d82
commit e1d2a31
Showing
2 changed files
with
22 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
# Instructions | ||
|
||
An anagram is a rearrangement of letters to form a new word. | ||
Given a word and a list of candidates, select the sublist of anagrams of the given word. | ||
Your task is to, given a target word and a set of candidate words, to find the subset of the candidates that are anagrams of the target. | ||
|
||
Given `"listen"` and a list of candidates like `"enlists" "google" | ||
"inlets" "banana"` the program should return a list containing | ||
`"inlets"`. | ||
An anagram is a rearrangement of letters to form a new word: for example `"owns"` is an anagram of `"snow"`. | ||
A word is _not_ its own anagram: for example, `"stop"` is not an anagram of `"stop"`. | ||
|
||
The target and candidates are words of one or more ASCII alphabetic characters (`A`-`Z` and `a`-`z`). | ||
Lowercase and uppercase characters are equivalent: for example, `"PoTS"` is an anagram of `"sTOp"`, but `StoP` is not an anagram of `sTOp`. | ||
The anagram set is the subset of the candidate set that are anagrams of the target (in any order). | ||
Words in the anagram set should have the same letter case as in the candidate set. | ||
|
||
Given the target `"stone"` and candidates `"stone"`, `"tones"`, `"banana"`, `"tons"`, `"notes"`, `"Seton"`, the anagram set is `"tones"`, `"notes"`, `"Seton"`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Introduction | ||
|
||
At a garage sale, you find a lovely vintage typewriter at a bargain price! | ||
Excitedly, you rush home, insert a sheet of paper, and start typing away. | ||
However, your excitement wanes when you examine the output: all words are garbled! | ||
For example, it prints "stop" instead of "post" and "least" instead of "stale." | ||
Carefully, you try again, but now it prints "spot" and "slate." | ||
After some experimentation, you find there is a random delay before each letter is printed, which messes up the order. | ||
You now understand why they sold it for so little money! | ||
|
||
You realize this quirk allows you to generate anagrams, which are words formed by rearranging the letters of another word. | ||
Pleased with your finding, you spend the rest of the day generating hundreds of anagrams. |