I saw a post on stack overflow and wanted to see if the davinci-codex model was smart enough to handle it. I feel like I’m close to making this work, but can’t quite put my finger on it.
What I have so far link here:
#: Explanation of what the code does This code creates a loop that draws points on a plot and then shows the plot to the user. #: Python 3 import matplotlib.pyplot as plt for i in range(1, 10): plt.plot(i, i**2, '-o') plt.show() #: Explanation of what the code does This code does the same as the above example, except that it also draws a line from the pervious point to the current point. #: Python 3
import matplotlib.pyplot as plt for i in range(1, 10): plt.plot(i, i**2, '-o') plt.plot([i-1, i], [i**2-1, i**2], '-o') plt.show()
The initial code creates this image:
As you can see the output is very close but not quite right.
If it had entered
plt.plot([i-1, i], [(i-1)**2, i**2], '-o') then we would have had the correct answer of
Any idea what I could be tweaking parameter wise to better help the system guess, or is there a more clear way I could have formatted my prompt to yield better results?