News for hackers. Stuff that matters.
Re:Can LLMs write better code if you keep asking them to "wr... by ryao on Friday January 03, 2025 @01:53PM (#42588408)
With this trick you can test while generating the random numbers and if you see both values, you can short circuit the generation of random numbers.
Re:Can LLMs write better code if you keep asking them to "wr... by bennythomsson on Friday January 03, 2025 @01:57PM (#42588449)
The input generation is outside the scope of this. Otherwise you could directly choose the output values with the apropriate distribution and just skip all the rest.

(Arguably, this criticism applies to exchanging random.randint for a numpy equivalent as well, since that doesn't optimize the solution but only how quickly the question is being generated.)

Re:Can LLMs write better code if you keep asking them to "wr... by ryao on Friday January 03, 2025 @02:25PM (#42588668)
Iterating a precomputed list is a method of generating random numbers. It is used in the one time pad. Whether we iterate a precomputed list or use a pseudo random number generator, we can short circuit the random number generator using this trick. We cannot directly choose the output values, because then it would not be random.
Re:Can LLMs write better code if you keep asking them to "wr... by minitech on Friday January 03, 2025 @04:47PM (#42589814)
They’re proposing choosing the output values randomly according to the distribution obtained by choosing input values uniformly at random for the original algorithm.
Re:Can LLMs write better code if you keep asking them to "wr... by ryao on Friday January 03, 2025 @07:52PM (#42591159)
That removes the random element to this. The way that random numbers work is that it is possible (although unlikely) that the minimum and maximal values in the range will not be selected when generating the million random numbers. If you assume that they will always be selected and thus always return the same output, then your output will be wrong at least some of the time.
Re:Can LLMs write better code if you keep asking them to "wr... by minitech on Saturday January 04, 2025 @06:41PM (#42598502)
I don’t know how you got “always return the same output” from “choose the output randomly according to [a non-uniform] distribution”.