javadictionaryinfinite

Making a Hyperwebster Dictionary


I just watched a VSauce video and he mentioned that the Hyperwebster dictionary consists an infinite amount of words, but each character after another is the next in the English alphabet. Under that logic, every name, joke, phrase, book, and insult has been written in the dictionary. Basically, it lists words like this: AAAAAA AAAAAB AAAAAC .. ZZZZZZ and this can be at any length. In my case, I just want a max of 3 characters (because that is 26^3 which is already a huge number, I don't want my compiler to break). I have a basic idea of how to do this, but I don't know how to apply each 'char' variable to be in order (as in ABC, not something random like QLD).

Another scenario I am interested in is making the first letter "index" so I can have it set to "Series A, Series B, etc.) but that would only add to the complexity. I want to be able to change the number of characters it will try to find. Also, I don't want a GUI obviously. Just output into the console.


Solution

  • I just wanted to know how I would go about doing something like this and how I can set it so it will create System.out.println(char1 + char2 + char3); and each output is a new thing like "aaa" "aab" "aac"

    This is a better specification than your original question. Here's a suggestion:

    char first = 'a';
    first++;
    System.out.println(first);
    
    >>>'b'
    

    Given the above behavior, we can write a loop:

    for (char first = 'a'; first <= 'z'; first++) {
        System.out.print(first);
    }
    

    Because chars have underlying number representations, which we can treat like integers, but since System.out.println looks for string representations of objects, when it sees a char type it knows to print the character, not the integer.