user
Scenario

A sailor signs up to a dating agency hoping to find a suitable mate.

The dating agency has 10 ladies on its books who may be suitable and uses the algorithm "all the nice girls love a sailor" to decide which ones to put forward for the sailor's consideration.

The sailor uses a different algorithm ("lady is lovable") to decide which ladies to actually date.

Task

Model this scenario in your language.

Give the sailor and ladies some names.

Use some arbitrary method based on the ladies' names to determine whether they're *nice* and/or *lovable*. For preference, choose a method where the outcomes are (more or less) equally likely.

Hence, determine which ladies the dating agency should suggest and which of these the sailor should offer to date.

Note

This task is intended as a bit of fun as well as a simple exercise in object modelling so hopefully it won't offend anyone!
assistant
Welcome to the **Arbitrary and Capricious Dating Agency**, (We don't use zodiacs, but we're just as arbitrary!)

```
use Digest::SHA1::Native;

my %ladies = < Alice Beth Cecilia Donna Eunice Fran Genevieve Holly Irene Josephine Kathlene Loralie Margaret
               Nancy Odelle Pamela Quinci Rhonda Stephanie Theresa Ursula Victoria Wren Yasmine Zoey >.map: -> $name {
    $name => {
        loves   => :16(sha1-hex($name).substr(0,4)),
        lovable => :16(sha1-hex($name).substr(*-4))
    }
}

my %sailors = < Ahab Brutus Popeye >.map: -> $name {
    $name => {
        loves   => :16(sha1-hex($name).substr(0,4)),
        lovable => :16(sha1-hex($name).substr(*-4))
    }
}

for %sailors.sort( *.key ) -> $sailor {
    printf "%6s will like: ", $sailor.key;
    say join ', ', my @likes = %ladies.sort( { abs $sailor.value.<loves> - .value.<loves> } ).head(10)».key;
    print '     Is liked by: ';
    say join ', ',  my @liked = %ladies.sort( { abs $sailor.value.<lovable> - .value.<lovable> } ).head(10)».key;
    my %matches;
    for @liked.reverse Z, (1..10) { %matches{.[0]} += .[1] };
    for @likes.reverse Z, (1..10) { %matches{.[0]} += .[1] };
    say 'Best match(s): ' ~ %matches.grep(*.value == %matches.values.max)».key.sort.join(', ');
    say '';
}

```

```
  Ahab will like: Eunice, Ursula, Irene, Holly, Fran, Genevieve, Zoey, Donna, Cecilia, Alice
     Is liked by: Nancy, Theresa, Victoria, Genevieve, Alice, Rhonda, Kathlene, Odelle, Eunice, Pamela
Best match(s): Eunice, Genevieve

Brutus will like: Beth, Nancy, Quinci, Odelle, Josephine, Kathlene, Theresa, Rhonda, Wren, Margaret
     Is liked by: Yasmine, Margaret, Loralie, Holly, Wren, Fran, Quinci, Eunice, Alice, Victoria
Best match(s): Quinci

Popeye will like: Loralie, Theresa, Stephanie, Yasmine, Alice, Cecilia, Donna, Zoey, Nancy, Genevieve
     Is liked by: Loralie, Margaret, Holly, Wren, Yasmine, Fran, Quinci, Eunice, Alice, Victoria
Best match(s): Loralie
```