Solving Programming Challenges using ChatGPT
Image by Jim Clyde Monge

Solving Programming Challenges using ChatGPT

Since everyone was trying out different things with ChatGPT and were being surprised and amused to see it generate amazing results which at times were spot on and at times it was not so correct .

I was thinking of different use cases and I wondered can ChatGPT generate a half decent code if I provided with a simple programming problem from HackerEarth . To start with, I selected the Perfect Sub Array problem , it had a success rate of 71% and it was a fairly decent problem . My query to it was fairly basic where i mentioned the exact problem , the input and output which the program needs to have

No alt text provided for this image

ChatGPT was able to generate a well documented code which to me was really good considering the fact that I had only mentioned the input and output and it interpreted the variable types correctly . Though the code was not very optimised .

No alt text provided for this image

So my next question was , is the code generated any good , and how well will it perform on the code submission. It actually was able to run faster than the best submissions for Java 14 and Python 3.8 , considering over 9.7K submissions were made and in its first attempt it was really good . But when it came to using memory , it was quite bad as can be seen from below that the program consumed huge amount of memory as compared to code written in other languages.

No alt text provided for this image
No alt text provided for this image

Final Verdict

In my opinion overall I was quite impressed by the well commented code and the fact that it was able to generate a working code to solve the problem . It might not be the best code that could have been generated but I guess it will be able to solve for some of basic programming interview rounds !

要查看或添加评论,请登录

社区洞察

其他会员也浏览了