Consider an application that has knowledge of all characters on the keyboard i.e. if asked to do so it can randomly choose any character and output it.
Now, in the programming language Java consider the simple code below:
public class Test {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
All it does is to print out Hello World. The code to compile the program requires 96 characters including spaces and should be exactly as above. For this example we are going to assume that there are 95 different characters which can be represented by the standard keyboard.
Now, if I instructed my application to choose 96 random characters, what is the probability that it would result in a hello world program ? only Hello World is acceptable not HELLO WORLD etc.
If it takes Java on average 0.2 seconds to compile code of length 96 characters and there is 0.2 seconds between each attempt how long would the worst case scenario take before succeeding ?
It's not infinite is it?
I considered for a long time where to post this question and seeing as the main approach here is to use maths I thought I would try here.