4 ms·
Is this the weirdest thing in C?
- tromp 2y agoThis weirdest thing has been a staple of entries in the IOCCC [1]. It is used not only to obfuscate, but also to save characters. For example, in this 1989 arbitrary length maze generator submission char*M,A,Z,E=40,J[40],T[40];main(C){for(*J=A=scanf(M="%d",&C); -- E; J[ E] =T [E ]= E) printf("._"); for(;(A-=Z=!Z) || (printf("\n|" ) , A = 39 ,C -- ) ; Z || printf (M ))M[Z]=Z[A-(E =A[J-Z])&&!C & A == T[ A] |6<<27<rand()||!C&!Z?J[T[E]=T[A]]=E,J[T[A]=A-Z]=A,"_.":" |"];} the Z[A-(E ... :" |"] expression spanning the last 3 lines saves 2 characters over the conventional alternative (A-(E ... :" |")[Z]. [1] https://www.ioccc.org/ https://www.ioccc.org/
- hbossy 2y agoI just tried to run it and all it produces is a single line and segfault: ./maze 136789 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ ._._._._._._._._._ Segmentation fault (core dumped)
- tromp 2y agoSee the compilation instructions on my webpage [1] under Section "Amazing". [1] https://tromp.github.io/pearls.html https://tromp.github.io/pearls.html
- deleted 2y ago[deleted]
- chunkyguy 2y agoC has many syntactic sugar and [] operator is one of them. -> is another popular one.
- NoZZz 2y agoOf course not, everyone knows that a[b] is equivalent to *(a+b)
- fargle 2y ago"the worst feature of C is that switches don't break automatically before each case label. This code forms some sort of argument in that debate, but I'm not sure whether it's for or against" https://www.lysator.liu.se/c/duffs-device.html https://www.lysator.liu.se/c/duffs-device.html (the original, better description) https://en.wikipedia.org/wiki/Duff%27s_device https://en.wikipedia.org/wiki/Duff%27s_device https://xkcd.com/1053/ https://xkcd.com/1053/