Faster way to do this?

achrist at easystreet.com achrist at easystreet.com
Wed May 21 01:48:28 EDT 2003


Freddie wrote:
> 
> Hi.
> 
> I was quite bored today, so I hacked up a quick Python script to do.. well,
> I'm not sure what it's called. You're given a set of letters ...

Here's a variation on the theme, useful to programmers everywhere
if we can solve it:

Given a set of menu and button commands, words or phrases, find
the best set of hotkeys to assign so that:

1. The hotkey letter for each command occurs in the command

2. Every command has a hotkey letter,

3. Best is defined as maximizing the number of hotkeys that
are the first letter of their command,  then the number of 
hotkeys that are the second letter of their command, etc.

Obviously, the problem is not always solvable at all.  When 
it is, is it an easy or a hard problem?  Will a greedy 
algorithm find an optimal solution? IDK.  I've never
had time to attack it.

Any ideas?


Al




More information about the Python-list mailing list