And this version, though too large to enter into the IOCCC, is not only valid C, but is additionally valid as COBOL, Pascal, Fortran, PostScript, a shell script, an MS-DOS .COM file, and Perl 5: https://ideology.com.au/polyglot/
> This program is (supposedly) the smallest C program able to print "Hello world.". The compilation itself produces the
desired printout and the program need not be actually run.
Oh, I think we can do better. C and bitwise operations are so 1980! Modern Hello Worlds should use modern languages, functional programming, and data science! Like so:
import numpy as np
x = np.array([0.03908342, 0.95362155, 0.95450865, 0.22260951, 0.35975305,
0.22841515, 0.3964834, 0.01782918, 0.05798498, 0.62697582,
0.69175475, 0.343705])
y = np.array([0.28685259, 0.40239044, 0.43027888, 0.43027888, 0.44223108,
0.12749004, 0.47410359, 0.44223108, 0.45418327, 0.43027888,
0.39840637, 0.1314741])
b = [lambda x, x0=x0: np.sqrt(.1+(x-x0)**2) for x0 in x]+[lambda x: 1., lambda x: x]
a = np.array([[bb(xx) for bb in b] for xx in x]+[[1.]*12+[0., 0.], list(x)+[0., 0.]])
c = np.linalg.solve(a, list(y)+[0., 0.])
print(''.join(chr(int(c.dot(np.array([bb(xx) for bb in b]))*251.+.1)) for xx in x))
I see lists, '+' signs, even an 'sqrt' in there. This is insane. Why would you ever use anything other than single-argumented lambdas in a python program? http://www.cip.ifi.lmu.de/~oster/fac.html
I have this: https://github.com/LanceH/fizzbuzz
in my back pocket just in case it is asked in an interview. I have the seed memorized to put in last while they're wondering what in hell I'm doing.
If the interviewer can't handle my sense of humor, then I'm not working there.
Cutesy reminder that regular fizzbuzz still filters out almost half of the candidates I receive for junior dev positions.
Some because they don't understand the requirements, some because they don't know how to use loops, some people they don't know how to use conditions, and yes some because they make overly complicated mess for no reason, or to try to be "super smart".
Hah, I remember having no clue what was going on the first time I read that, but it clicked just now. The fizzbuzz problem as described in that paragraph could almost be interpreted as 3 equations. The math was for something along the lines of this problem:
Enterprize FizzBuzz has been one of my favourite things for a while. It perfectly captures the attitude where I used to work, where people felt that by adding later upon layer of obfuscation they were doing engineering.
I don't think any of these are particularly convoluted; they're in straightforward procedural code with a line for each letter. Most programmers could adapt the code to produce another string without too much effort.
What I'd consider convoluted is something like the Goodstein sequence[1] which would grow to monstrous proportions using far more memory than could be stored even if every particle in the universe represented one bit and far more time than beyond when the last black hole has evaporated, yet collapsed down (eventually) to "Hello World". (I've no idea how to do this.)
It occurred to me that this is maybe just marginally more unreadable than a Hello world for Android or iOS or other desktops after all the boilerplate code and resources has been added. And it still is easier to compile.
My attempt from many years ago in GWAAAAAAAH. A brainfuck like programming language, for crazy rabbits where most characters are ignored and only for style.
This seems kind of lightweight. There should surely be a web implementation that uses Docker, k8s, React, Typescript, Node, MongoDB, AWS, and GitHub, and still only works correctly in a specific version of IE8.
Good for a beginner effort, but its not really all that convoluted or obfuscated. The problem is that 90% of the obfuscation is in the removal of whitespace. Pretty print the final thing, and it isn't so bad (the 2nd to last listing is pretty easy to follow). Things like 0-1 or 13*1 + 3, etc add some noise but are not particularly hard to parse or understand, the ternary is ugly but it's sequential so nothing up the sleeve there, the memcpy are just a noisy one character assignment.
The author should review the IOCCC submissions posted earlier. Like holloway.c.
This could be "improved" to make it get a sound "Hello World" instead of a visual one. I mean it's still "Hello World" and I feel sound gets too little credit versus graphics.
Should output "hello, world!\n" (Kernighan, A Tutorial Introduction to the Language B, 1972) or "hello, world\n" (Kernighan, Programming in C: A Tutorial 1974 and Kernighan/Ritchie, The C Programming Language 1978).
My eye balls hurt after looking at the final version of hell world. But a job very well done I must say. Could go even more insane with inline assembly but I’ll wait for part two for that :)
I like how there is the comment "you can't forget \0" for r[12] in the first example... but he forget it in the second haha.
You should use calloc in that case !
A simple standard C++ hello world introduces: functions, ctors, dtors, headers, header guards (you are including headers right away), namespaces (std, anonymous), operator overloading (<<), function overloading, pointer to function (endl), templates, traits, locales, streams (basic_ostream), lifetimes (cout), move operations, inheritance, static initialization (in locales) and a bunch of other things I surely missed.
There's no limit to how many arrays you can xor together to get "Hello, World!". They're all essential in the sense that removing any of them causes the result to fail. I am interested in awkward and arbitrary code optimization problems like code golf. But you can just take this one to infinity in a number of different ways.
Just my opinion but seeing how compiler behaves with each of them would have been much more interesting, for now it's just a hacky-ish way of getting the ascii codes.
We're not trying to make this easy :) We need some computer vision code to search the display buffer itself to find out where the terminal is and figuring out where to draw the pixels!
https://www.ioccc.org/1992/lush.c
https://www.ioccc.org/1989/jar.1.c (cf. https://www.ioccc.org/1989/jar.1.hint)
https://www.ioccc.org/1986/applin/applin.c
https://www.ioccc.org/1986/holloway/holloway.c
https://www.ioccc.org/1985/applin/applin.c
https://www.ioccc.org/1984/anonymous/anonymous.c
And this version, though too large to enter into the IOCCC, is not only valid C, but is additionally valid as COBOL, Pascal, Fortran, PostScript, a shell script, an MS-DOS .COM file, and Perl 5: https://ideology.com.au/polyglot/
You may not like it, but...
P.S. if you liked this comment, you'll love https://news.ycombinator.com/item?id=23183383!