3 ms·
This is a nice idea. I like it. It can certainly be confused by adversarial function and variable names or comments, but that is to be expected. I think maybe
by vintermann 4y ago
This is a nice idea. I like it.
It can certainly be confused by adversarial function and variable names or comments, but that is to be expected.
I think maybe it's a bit verbose and eager to explain the obvious step by step. I'd rather it recognize the algorithm, describe it with its proper name and possibly point out any errors it sees. For instance, I gave it the following code
def enc(num, symbols="ab"):
ret=''
slen = len(symbols)
while num > 0:
num -= 1
ret = symbols[num % slen] + ret
num = num // slen
return ret
... and it described step by step what it does, but did not know it's called "encoding a number in bijective base", or otherwise give any hints why someone might want to encode a number this way.
edit: I tried giving it the decoder too, and added a comment # what do these two mystery functions do??
as a hint to try to get it to explain more generally rather than step by step. It did correctly infer that it was a change of base, but it did not know about bijective base.