3 ms·
Has anybody tried code reviews? As in "GPT-3, please do a code review of this code".
by 323 4y ago
Has anybody tried code reviews? As in "GPT-3, please do a code review of this code".
- goodside 4y agoFor small examples, yes, it works: Prompt: Perform a code review of the following module, identifying any bugs: ``` #!/usr/bin/env python3 def fib(n): """Return n-th Fibonacci number.""" if n <= 2: return 1 else: return fib(n-2) + fib(n+1) ``` GPT-3 completion: The bug in this module is that the n+1 parameter in the return statement should be n-1. But don't expect miracles on real-world files, because GPT-3 struggles with long-term dependencies in text (e.g., remembering what happened ~4000 characters ago).
- zitterbewegung 4y agoSeems to work for a factorial function also Perform a code review of the following module, identifying any bugs: ``` #!/usr/bin/env python3 def factorial(x): """This is a recursive function to find the factorial of an integer""" if x == 1: return 1 else: # recursive call to the function return (x * factorial(x+1)) ``` A: The bug in this code is that the function is attempting to find the factorial of an integer by recursively calling itself with an incremented value. This will cause an infinite loop. But if you unindent and then also perform the n+1 error it only will see the unindent issue. Perform a code review of the following module, identifying any bugs: ``` #!/usr/bin/env python3 def factorial(x): """This is a recursive function to find the factorial of an integer""" if x == 1: return 1 else: # recursive call to the function return (x * factorial(x+1)) ``` A: The code will not run because there is a syntax error on line 6. The indentation is incorrect. The return statement should not be indented.
- deleted 4y ago[deleted]
- jggggggggggggj 4y ago