Come up with the most inefficient, poorly written, and complex way to print out "Hello World!".
29 16 Jul 2015 20:01 by u/jped
I got bored today sitting at home and thought about doing this.
edit: its always fun to take things to extreme
29 16 Jul 2015 20:01 by u/jped
I got bored today sitting at home and thought about doing this.
edit: its always fun to take things to extreme
39 comments
29 u/OTL_ 16 Jul 2015 22:12
https://veuwer.com/i/2v3m.gif
Not really poorly written, but definitely inefficient and complex.
2 u/jped [OP] 17 Jul 2015 00:11
I'm not 100% sure what is going on, but I love it.
4 u/OTL_ 17 Jul 2015 00:17
When writing files on a computer, it's written with bits. The file extensions or what program you open them with is how you expect the bits to interpreted. In a .bmp, the bits are meant to be interpreted as colours but if you open it in notepad then it interprets those bits as text.
0 u/jped [OP] 17 Jul 2015 00:21
So you wrote C code in Paint?
1 u/OTL_ 17 Jul 2015 00:28
Not quite, I wasn't the one who wrote the one in the gif, I found it here on stack overflow. However I have reproduced it by writing the c++ code first and then opening it up in paint. Then you add some bogus values to make it a rectangle without changing the rest of the bits that actually contain the code. Go backwards from there and voila!
In theory this could work with any program you want, just depends on the kind of determination you have.
0 u/ImSureImPerfect 18 Jul 2015 07:28
I will never be this good at any sort of programming.
I have no words for how impressed I am by the dedication it must take to write C++ in MSPaint.
1 u/OTL_ 18 Jul 2015 10:57
0 u/Camarilla 17 Jul 2015 16:01
Files do start off with "Magic Numbers" that tell the computer what type they are, but a whole lot of programs are content to ignore them.
1 u/anonagent 18 Jul 2015 10:22
You did not do this, this has been on the internet for years
1 u/OTL_ 18 Jul 2015 10:54
I never claimed to have made this .gif.
0 u/flat_hedgehog 19 Jul 2015 03:44
I'm impressed.
17 u/Cool_Breeze 16 Jul 2015 20:43
http://i.imgur.com/Okjh4Ux.jpg
2 u/Naught405 16 Jul 2015 22:59
you win, here have 1 internet
9 u/14d2025 16 Jul 2015 20:39
Concepts:
Get random character from Unicode-32 one-by-one until they combine to "Hello World!" and then print it.
Generate random string, calculate hash (md5/SHA-1/whatever) until it will get "Hello World"
Download random image from igmur/tumblr/veuwer whatever calculate hash until you get "Hello world"
Calculate number Pi until its substring is "Hello world!" (ASCII encoded)
Find (m, n) for Ackermann_function when the value is equal to ASCII representation of "Hello World"
Feel free to implement and share when you are done.
9 u/rwbj 17 Jul 2015 01:44
Hello world you say? How about a sort of genetic algorithm to try to intelligently come up with Hello World! knowing and using nothing except a customizable suitability method?
The following code is written for a C# forms window. Simply add a textbox named outputTextBox and a button named goButton with a click event goButton_Click. Alternatively it'd be trivial to port to a console app, but I'm lazy(?). Variables that might be fun to play with are consted and all caps. This program probably has bugs and is undoubtedly poorly written. Enjoy!
1 u/rwbj 17 Jul 2015 01:45
Sample output where it just couldn't get it:
2 u/ShowMeYourGenitals 17 Jul 2015 07:38
Love the "GeneticLotteryWinner"!
5 u/PasswordIsTaco 16 Jul 2015 20:55
I have thought of a horrible way to do it, but it would take so long to test that I can't really write it. Basically, continually calculate Pi, converting each digit into binary, then look for the binary representation of 'hello' and then do it all again for 'world'. Then take those indexes, and generate pi again to get to that index, and print the ascii representation of that part. Stupid and inefficient? Most definitely!
They'll be in there somewhere (and here's the locations: hello and world). If you remove the space and punctuation, you'd be looking a LOT longer (exponentially longer, I imagine ;) ). It's not in the first 4 billion digits.
Capitalisation and punctuation while looking for the exact string would probably turn this into something that takes longer than your lifetime.. I don't know.
2 u/briamah 16 Jul 2015 20:40
Love the idea sort of a digital rube goldberg machine...
2 u/Dragonstrike 16 Jul 2015 20:56
Generate white image of a random size and flip a random number of pixels to black. If the number matches the ascii code of the correct letter, print the letter to the screen. Repeat until entire string is printed.
Entirely coded in assembly, of course.
2 u/zoophobia 16 Jul 2015 21:02
http://jroweboy.github.io/c/asm/2015/01/26/when-is-main-not-a-function.html Here is a great article, on a hello world program.
2 u/DinoRider 16 Jul 2015 21:16
I've read that before and it takes the cake here. I'd be willing to bet there's an old precedent for it somewhere in the history of the obfuscated coding contest.
The only thing I can think of that matches that is a huge mess of nested and/or recursive function calls and callbacks that somehow puts together the correct string in the end. I don't have the tools an old C programmer has.
1 u/ElementalPee 16 Jul 2015 21:53
That reminded me of this thing. The Evolution of a Programmer.
1 u/14d2025 19 Jul 2015 02:29
Use particles: Hello world
0 u/Cuddlefluff 16 Jul 2015 22:25
How about examining PI to find the machine instructions in sequence to print it
0 u/Naught405 16 Jul 2015 23:07
Create a hash table for ascii values to voltage read from a photodiode sensor, re-arrange the table based on east/west gps coordinates and select an entry based on n/s coordinates. travel to a location that has the proper light conditions and gps coordinates to print 'H' repeat until "Hello world!" is printed. Assuming this is all on a microcontroller you need to write the program itself as well as drivers for photodiode, lcd display and GPS.
I come from robotics, what is this 'UI' everyone keeps jabbering about?
0 u/JeffreyARobinson 16 Jul 2015 23:25
In theory (I tried and can't get it to totally work) you should be able to generate a huffman tree in which The encodings of "Hello World!" results in the output of "Hello World!".
0 u/reluctantvoatuser 17 Jul 2015 00:01
Something, Something, InterCal.
0 u/jped [OP] 17 Jul 2015 00:14
Wow everyone else's is so good, but I just finished my first year of CSCI at uni so this is the best I could do other than making a class for each letter.
0 u/ShowMeYourGenitals 17 Jul 2015 01:58
Run a loop with a Sleep(3000) in it. Have your computer generate a random number, sum down the digits until you reach a number under 26, and if it corresponds to the letter of the alphabet you want, reboot the computer, zero out your free disk space, calculate pi to 30303030303030 places... etc......
0 u/RevanProdigalKnight 17 Jul 2015 04:31
Write a JavaScript parser for a Python parser for a BF parser for a Lisp parser for a program that has a basic structure like this:
0 u/rhabarba 17 Jul 2015 11:45
Why not Python?
0 u/nicky_haflinger 17 Jul 2015 17:27
bogosort is a great place to start with stuff like this try this pseudocode alloc all unassigned disk fill it with binary garbage one bit at a time by randomly picking a bit location and then running an iterative checksum on the TB image where your iterator is 0 to free mem of the system choose a random number between 0 free mem size fill up the buffer by picking random offsets into you disk image. toss the disk image and write the mem pool to disk. compare your new disk image to hello world by asking a human if this is what they're looking for. if not recurse.
You can also take the human step out with intentionally super-slow comparisons.
0 u/ImSureImPerfect 18 Jul 2015 07:27
Not the best/silliest answer, but definitely inefficient. First thing that came to mind.
0 u/rdnetto 18 Jul 2015 18:36
0 u/bontoJR 20 Jul 2015 11:44
0 u/Master_Foo 21 Jul 2015 05:55
0 u/rsa 04 Aug 2015 19:00
Another difficult way to do it is to use the language Malbolge.