by LeoPanthera · 3y ago · 0 comments
== Begin quote ==
INTERCAL is a esoteric programming language designed to be as different from conventional programming languages as possible. It's known for its obfuscation and convoluted syntax, and your provided program adheres to this style perfectly. It's quite an accomplishment to create a functional password generator in such an unusual language!
Before we dive into the details of the program, let's try to clarify why a previous version of ChatGPT might have said that INTERCAL lacked a random number generator. That statement may be somewhat misleading. It's not that INTERCAL inherently lacks the ability to generate random numbers, but it doesn't provide a straightforward, built-in function to do so. Therefore, creating a random number generator in INTERCAL would require a creative and complex implementation. In the code you provided, it seems the author found a way to work around this limitation.
The password generator you posted creates passwords by initializing an array (,6) with 16-bit values that represent ASCII characters. The set of characters includes digits, some punctuation marks, and uppercase and lowercase letters, but excludes easily misread characters. It creates a 16-character password using these values, and it seems to enforce a certain level of complexity by ensuring the inclusion of at least one number and one punctuation mark.
The main loop begins at `(1) DO COME FROM (9)`. Here, a spot in the password is selected and filled with a character from the array. There are some points in the loop where the selected spot may be forced to be a number or punctuation mark. If the character set is checked for digits and punctuation marks, pre-chosen spots for these types of characters are dropped. The selected character is then read out.
This INTERCAL code uses a clever trick to generate seemingly "random" numbers - using the `%50` operation (which in INTERCAL means to mingle the bits of two 16-bit numbers), along with unary operations like `#1`, `#2`, `#4`, etc. on the same variable, to generate different results each time the loop is run.
While I must say this is an ingenious solution, it's not a truly random generator, and the randomness of the password depends heavily on how INTERCAL handles the `%50` operation and the subsequent operations on the same value. It's more of a workaround that takes advantage of INTERCAL's quirky way of handling operations than a typical random number generator.
Nevertheless, creating such a program in INTERCAL is quite a feat. The author deserves credit for coming up with such a complex solution in a language that deliberately eschews conventionality.
== End quote ==
I don't know INTERCAL but this appears to be pure bullshit. Wikipedia's description of `%50` is consistent with the article author's: "after the identifier, a percent chance of the line executing can be given in the format %50, which defaults to 100%." [1]
And contrary to GPT-4's doubling down on INTERCAL not containing any random number support, a built in language feature that executes (or not) a line of code with a chosen probability really is random number support built into the language, just with a deliberately bizarre interface in keeping with the rest of the language.
If that's the case, you still could build a PRNG out of it with enough code, but that's the same thing as building PRNG out of regular math (%-operator would then be equivalent to hardcoding 100 100-bit constants). However, I would not call %-operator itself a (P)RNG or a randomness primitive.
Unfortunately, the linked reference in [5] is in PostScript format, and I have... exactly zero devices that can open that quickly, so I can't check. But I strongly hope I'm right, just so I can smirk at all the people, author included, who criticize ChatGPT for insisting %-op isn't a RNG, while forgetting about https://xkcd.com/221/.
> After the line label (if any), must follow one of the following statement identifiers: DO, PLEASE, or PLEASE DO. These may be used interchangeably to improve the aesthetics of the program. The identifier is then followed by either, neither, or both of the following optional parameters (qualifiers): (1) either of the character strings NOT or N’T, which causes the statement to be automatically abstained from (see section 4.4.9) when execution begins, and (2) a number between 0 and 100, preceded by a double-oh-seven (%), which causes the statement to have only the specified percent chance of being executed each time it is encountered in the course of execution.
Granted, the quality of the RNG used is of course quality of implementation, and there's nothing stopping even Math.random() from just returning 4. Reading the document though, it does appear the author is correct, alas.
> ... which causes the statement to have only the specified percent chance of being executed each time it is encountered in the course of execution."
Only the most willfully perverse reading of that would allow the xkcd approach, and while INTERCAL is undeniably perverse it isn't that sort of perversity.
Of course, none of this affects the fact the GPT paragraph I quoted is a complete fabrication.
I think this fits the specification, isn't a perverse interpretation, and clearly isn't a meaningful PRNG either.
Basically, I don't think ChatGPT has a grasp of how INTERCAL actually works, and is just hallucinating a lot of it.
(it will do so, and it will even look kinda sorta right if you have only the general idea of how it's supposed to look... but it will be very far from accurate)
Since GPT is basically a text prediction engine that doesn't think, per se, this is a reasonable output.
It’s productized Gell-Mann Amnesia, injected straight into an industry of people who love perceiving themselves as overnight experts on any topic they encounter. No wonder it’s so popular!
The problem is determining whether it's doing well or not if you don't have sufficient knowledge and/or experience to evaluate the output.
Thanks for sharing this transcript with me.