Efficient word scramble algorithm

前端 未结 4 1679
情歌与酒
情歌与酒 2020-12-30 06:13

I\'m looking for an efficient algorithm for scrambling a set of letters into a permutation containing the maximum number of words.

For example, say I am given the li

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-30 06:57

    You might try simulated annealing, which has been used successfully for complex optimization problems in a number of domains. Basically you do randomized hill-climbing while gradually reducing the randomness. Since you already have the Aho-Corasick scoring you've done most of the work already. All you need is a way to generate neighbor permutations; for that something simple like swapping a pair of letters should work fine.

提交回复
热议问题