Friday, March 29, 2024
HomeSample Page

Sample Page Title


Since the tag wasn’t added, I wrote an algorithm using YAWL to show that;

the longest doable phrases are $6$ letters lengthy, and there are solely $5$ of them.

They are;

dearns, heards, shoots, spared, and yeard.

Of these, solely:

shoots is taken into account “legitimate” as a result of hoots, soots, pictures (will be fashioned twice), shoos, and shoot are all legitimate phrases too.

I verified it as a legitimate “Scrabble” phrase utilizing this web site.


Even although it did not depend, the one I discovered essentially the most fascinating was:

spared as a result of it is variants are; pared, sared, spred, spaed, spard, and spare. Most of those I’d have by no means considered legitimate phrases.

Fun truth;

there are $201$ phrases that, with precisely one letter faraway from any place within the phrase, nonetheless varieties one other phrase in YAWL. There are fewer nonetheless that might be thought-about legitimate in a Scrabble dictionary (not considerably fewer, however I do not need to search for 201 phrases by hand).

The algorithm I created labored by:

beginning with all phrases with $15$ letters (the longest doable phrase size in Scrabble) and eradicating $1$ letter from every index within the phrase. It then checked the complete $14$ letter glossary to see if all of those candidates had been contained inside it. This course of repeated all the best way down by means of the $4$ letter glossary, which you proved by yourself may simply present a phrase.

For these , here is the C# code that powered my reply: [1]

utilizing System;
utilizing System.Collections.Generic;
utilizing System.Linq;
utilizing BruteForceDictionary;
static void Main(string[] args) {
    Console.WriteLine("Starting");
    var lists = new List<List<string>>();
    for (int i = 15; i > 3; i--) {
        foreach (var phrase in PhraseLists.AllPhrases.Where(w => w.Length == i)) {
            var phrases = ChaseWords(phrase);
            if (phrases?.Count > 0) {
                lists.Add(phrases);
                Console.WriteLine(string.Join(";", phrases));
            }
            else
                Console.WriteLine($"No outcomes discovered for '{phrase}'.");
        }
    }

    Console.WriteLine("Writing maximums.");
    int max = lists.Max(m => m.Count);
    foreach (var checklist in lists.Where(w => w.Count == max))
        Console.WriteLine(string.Join(";", checklist));

    Console.WriteLine("Done");
    Console.ReadKey();
}
public static List<string> ChaseWords(string candidate) {
    var strippedWords = GetVariants(candidate);
    var nextSet = PhraseLists.AllPhrases.Where(w => w.Length == candidate.Length - 1);
    if (strippedWords.All(a => nextSet.Any(n => n.Equals(a)))) {
        strippedWords.Insert(0, candidate);
        return strippedWords;
    }

    return null;
}
public static List<string> GetVariants(string phrase) {
    var outcome = new List<string>();
    for (int i = 0; i < phrase.Length; i++)
        outcome.Add(phrase.Remove(i, 1));

    return outcome;
}

Fun puzzle!

1: The utilizing directive for BruteForceDictionary is offered by my private “arduous coded” model of YAWL, accessible on my GitHub when you want it for replica functions.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments