Goku-kun / 1000-ways-to-print-hello-world-in-python

This is a public repository where the aim is to print "Hello, World!" in all different possible ways.
63 stars 73 forks source link

Added code to print "hello world" by permuting ASCII dictionaries #96

Closed darahaas15 closed 2 years ago

darahaas15 commented 2 years ago

This creates a dictionary of ASCII values and their associated characters as it will permit the code to only use those values and nothing else. Having done that, we create a list of dictionaries with set rules defining the word length, its first, last, and repeating characters, and then also set a true/false statement for if repeats should be checked. Once this is done, the script iterates through the list of dictionaries and feeds it through a function that creates all possible permutations of characters from the reference dictionary, taking care to add any repeating characters if necessary.

Afterward, it is then fed through a second function that creates even more permutations for each permutation, but setting a maximum length. This is done to ensure that we find the words that we want to chew through. During this process, it then feeds it through a function that uses a combination of if-else statements that determines if it is worthy of being spat out. If the permutation matches what the statements are calling for, it then spits out a true/false statement and the function that called it adds it to a list.

Once this is done, the script then takes the first item from each list and combines them to state "hello world".