6 ms·
Here's mine, from 1986 or so. I still use it all the time: #include <stdio.h> #define O1O printf #define OlO putchar #define O10 exit #defi
by WalterBright 3y ago
Here's mine, from 1986 or so. I still use it all the time:
#include <stdio.h>
#define O1O printf
#define OlO putchar
#define O10 exit
#define Ol0 strlen
#define QLQ fopen
#define OlQ fgetc
#define O1Q abs
#define QO0 for
typedef char lOL;
lOL*QI[] = {"Use:\012\011dump file\012","Unable to open file '\x25s'\012",
"\012"," ",""};
main(I,Il)
lOL*Il[];
{ FILE *L;
unsigned lO;
int Q,OL[' '^'0'],llO = EOF,
O=1,l=0,lll=O+O+O+l,OQ=056;
lOL*llL="%2x ";
(I != 1<<1&&(O1O(QI[0]),O10(1011-1010))),
((L = QLQ(Il[O],"r"))==0&&(O1O(QI[O],Il[O]),O10(O)));
lO = I-(O<<l<<O);
while (L-l,1)
{ QO0(Q = 0L;((Q &~(0x10-O))== l);
OL[Q++] = OlQ(L));
if (OL[0]==llO) break;
O1O("\0454x: ",lO);
if (I == (1<<1))
{ QO0(Q=Ol0(QI[O<<O<<1]);Q<Ol0(QI[0]);
Q++)O1O((OL[Q]!=llO)?llL:QI[lll],OL[Q]);/*"
O10(QI[1O])*/
O1O(QI[lll]);{}
}
QO0 (Q=0L;Q<1<<1<<1<<1<<1;Q+=Q<0100)
{ (OL[Q]!=llO)? /* 0010 10lOQ 000LQL */
((D(OL[Q])==0&&(*(OL+O1Q(Q-l))=OQ)),
OlO(OL[Q])):
OlO(1<<(1<<1<<1)<<1);
}
O1O(QI[01^10^9]);
lO+=Q+0+l;}
}
D(l) { return l>=' '&&l<='\~';
}
I do like the colorized output of hexyl, though.
- cornstalks 3y agoWas this for an obfuscated C challenge?
- pmoriarty 3y agoHere's how Claude+[1] explained it: This program appears to be a hexadecimal dump utility. It does the following: - It takes a filename as a command line argument and opens that file for reading - It reads the file byte by byte until EOF - For each byte, it prints the hexadecimal value of the byte, in the format "%2x " (i.e. 2 hex digits, a space) - After every 16 bytes, it prints the ASCII representation of those bytes, replacing non-printable characters with "." - It also has some obfuscated logic with bitwise operations, likely attempting to confuse the reader. So if you ran it like this: ./program myfile.txt It would output something like: 54 65 78 74 20 66 69 6c 65 2e 0a 54 68 69 73 20 69 73 20 61 20 74 65 78 74 20 66 69 6c 65 2e 0a 54 68 65 20 71 75 69 63 6b 20 62 72 6f 77 6e 20 66 6f 78 0a 6a 75 6d 70 73 20 6f 76 65 72 20 20 74 68 65 20 6c 61 7a 79 20 64 6f 67 0a 2e 2e 2e Which is the hexadecimal dump of the ASCII contents of myfile.txt. The #defines are used to obfuscate the code and make it harder to read, replacing printf with O1O, putchar with OlO, etc. The D() function is used to check if a byte is a printable ASCII character. So in summary, this program opens a file, reads it byte by byte, prints the hex values, and prints the ASCII for printable characters, as a hexadecimal dump utility. [1] - https://poe.com/Claude%2B https://poe.com/Claude%2B
- pmoriarty 3y agoAfter seeing an LLM do something like this, I've got to ask people who think that LLMs are just "stochastic parrots", "just predicting the next word", or are merely "a blurry jpeg of the web" to think about what's really going on here.
- nwiswell 3y agoThis exact code appears online as part of the IOCCC 1986 (it was a submission), so it's likely that this was indeed part of the training set for this LLM and that there is a significant corpus of text discussing this particular program and other obfuscated programs like it. I'm not ruling out that this LLM output is "partially organic" rather than "fully regurgitated", but I'd be much more interested to see this LLM explain an obfuscated program that hasn't been floating around the Internet for 35 years.
- pmoriarty 3y agoIt's easy to test it with something unpublished
- tomjakubowski 3y agoMy experience is that ChatGPT does a very poor job writing Brainfuck programs for me, even simple programs like "add two and two" aren't correct. Maybe it would do better if I asked it to explain one instead.
- makach 3y agoWhat have you done..!?