A word $$k$$ is a kangaroo if you can obtain one its synonyms $$j$$ by discarding letters from $$k$$. That synonym $$j$$ is called the joey of the kangaroo $$k$$. Some examples:
kangaroo | joey |
---|---|
action | act |
alone | lone, one |
allocate | allot |
blossom | bloom |
capable | able |
container | can, tin |
chicken | hen |
disappointed | sad |
kangaroo | joey |
---|---|
feast | eat |
inflammable | flammable |
latest | last |
malignant | malign |
masculine | male |
myself | me |
gigantic | giant |
signal | sign |
Terminology is derived from the fact that kangaroos carry their young — known as joeys — in a body pouch. Likewise, kangaroo words carry their joey words within themselves.
A twin kangaroo is a kangaroo that contains two joeys: container carries both tin and can.
An anti-kangaroo is a word that contains its antonym: covert carries overt, and animosity carries amity.
A grand kangaroo is a kangaroo which has two joeys, one of which is in the pouch of the other. For instance, alone is a grand kangaroo since it contains lone, which carries its own synonym one.
Write a function kangaroo that takes two words $$k$$ (str) and $$j$$ (str). The function must return a Boolean value (bool) that indicates if $$k$$ is a kangaroo with joey $$j$$.
Write a function joeys that takes two arguments: i) a word $$k$$ and ii) a container (list, tuple or set) of words (str). The function must return a set containing all joeys (str) of $$k$$ that appear in the given container of words.
The functions kangaroo and joeys may not make a distinction between uppercase and lowercase letters in determining kangaroos and their joeys.
>>> kangaroo('blossom', 'bloom')
True
>>> kangaroo('DISAPPOINTED', 'SAD')
True
>>> kangaroo('GIGANTIC', 'giant')
True
>>> kangaroo('ALONE', 'lone')
True
>>> kangaroo('Marsupial', 'Kangaroo')
False
>>> joeys('blossom', ['bloom', 'bud', 'floweret'])
{'bloom'}
>>> joeys('DISAPPOINTED', ('SAD', 'DOWN', 'UPSET', 'FOILED'))
{'SAD'}
>>> joeys('GIGANTIC', {'giant', 'colossal', 'huge', 'massive', 'enormous', 'immense', 'vast'})
{'giant'}
>>> joeys('ALONE', {'lone', 'one', 'only', 'solo', 'unaccompanied'})
{'lone', 'one'}
>>> joeys('Marsupial', ['Kangaroo', 'Wallaby', 'Koala', 'Opossum', 'Wombat'])
set()