-2

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.

lucas
  • 1
  • 3
  • 1
    Do you have a specific question or are you looking to hire a developer? – shmosel Jul 14 '17 at 23:49
  • this is a question. – lucas Jul 15 '17 at 00:08
  • I see no question. – shmosel Jul 15 '17 at 00:09
  • Oh, it cut out. 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" – lucas Jul 15 '17 at 00:15
  • I get what you want, but that's not how this site works. Show some attempt and explain where exactly you need help. Otherwise, you're basically asking for a free coding service. – shmosel Jul 15 '17 at 00:23
  • While the question itself may be perfectly valid, phrasing it correctly and showing your own effort is extremely important. Since noone is paying money here for solving other people's problems, it's up to **you** to convince us to help :) https://stackoverflow.com/help/how-to-ask – alex Jul 15 '17 at 00:29
  • Understandable. I'm a new developer trying to learn basic concepts. Thought this was the right site as I saw people asking how to do stuff too. – lucas Jul 15 '17 at 00:31
  • That doesn't make it ok. Lots of people ask off-topic or lazy questions and they're quickly downvoted and deleted. But I'll help you out anyway: http://ideone.com/wFk62G – shmosel Jul 15 '17 at 00:39
  • Relevant: https://libraryofbabel.info – Nick is tired Jul 15 '17 at 01:04
  • Thank you shmosel. I changed the "Ideone" class name to "words" (because that is what my class is called for this) and it only lists every number from 86574 to 99999. – lucas Jul 15 '17 at 01:07
  • It's just cutting off older output. – shmosel Jul 16 '17 at 23:54

1 Answers1

2

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.

MyStackRunnethOver
  • 4,872
  • 2
  • 28
  • 42
  • That outputs b, as you said, but then how would I output a? Also, how can I do a while that looks like: `if(first < 26){ System.out.println(first); first++ }' so that will repeat until 26, but its a char. How can I make it list 'aaa' 'aab' 'aac' and so on until I reach 'zzz' – lucas Jul 15 '17 at 00:55
  • 1
    @Lucas thats for you to figure out, this is a good answer providing a basis on which you can continue, rather than just giving you the answer – Nick is tired Jul 15 '17 at 01:01
  • @LucasSkarpness I edited my answer to give an example of how you can loop over characters (as opposed to the normal method of looping over integers). If you get stuck moving forward, it's probably different enough that you should ask a new question – MyStackRunnethOver Jul 15 '17 at 01:05
  • Only error it gave was that on the line that says 'for (char first = 'a', etc.) is a duplicate variable of 'first'. Wants me to change it to first1. – lucas Jul 15 '17 at 01:12
  • Nevermind realized the second example is different. Thank you! – lucas Jul 15 '17 at 01:13
  • @LucasSkarpness if you're satisfied please accept my answer, so that the question is seen as answered – MyStackRunnethOver Jul 17 '17 at 19:45