find the most beautiful string according to specific ruleset