This article has participated in the good article call order activity, click to see: back end, big front end double track submission, 20,000 yuan prize pool for you to challenge!

The github Copilot technology preview application submitted earlier received an admission email today, so I set up a lot of copy to try this copy that is going to send me to work at the electronics factory?

Website and application address: Copilot.github.com/


The composition contains the following contents:

  • This section describes copilot
  • Do some simple usage tests with Copilot in Python
  • Use Copilot to solve the LeetCode problem

A brief introduction to Copilot

Github copilot, currently available only as an extension to vscode, relies on github’s billions of publicly available code bases to train AI coding AIDS (including full-line code offering or function suggestions) in dozens of programming languages. The technical preview works particularly well for Python, JavaScript, TypeScript, Ruby, and Go.

How it works: The AI model is trained from a large common code base and built into A Copilot service. The service receives the feed code returned by the Copilot plug-in and provides code suggestions. The plug-in in turn sends back the adoption of the suggestions from the programmer to Copilot service, repeatedly reinforcing the AI model.

Here is a summary:


Do some simple use tests on Copilot using Python

In the vsCode plugin we install Github Copilot and create a test file, copilot_test.py

1. A function that gets the maximum and minimum values of a list

What we’re going to write might look something like this

'''
Function to get the max and min values of a list
'''
def get_max_min(my_list) :
    max_value = max(my_list)
    min_value = min(my_list)
    return max_value, min_value
​
def main() :
    my_list = [1.2.3.4.5]
    max_value, min_value = get_max_min(my_list)
    print("Max value:", max_value)
    print("Min value:", min_value)
    
if __name__ == "__main__":
    main()
​
Copy the code

Comments are a key part of Copilot, all AI is big data based applications, even think of Copilot simply as a retrieval of github code base…

2. A calculator

The suggestions that Copilot gives us allow us to select and use Alt+[,Alt+] to look up and down the suggestions.

We can use Ctrl+Eeter to open the suggestion result panel, and we can see that copilot gives us 10 solutions for these suggestions


Use Copilot to solve LeetCode problem

Let’s find a question [palindrome number] in LeetCode, and the topic is as follows:

And then we put them in the code comments

The code area classes are also added

It looks like this is what our code looks like, as suggested by the Grey Code copilot

Let’s take a look at one of these suggestions in the LeetCode implementation

This advice doesn’t seem ideal… Brave Niuniu is not afraid of difficulties, interested students can see the problem of difficulty mode oh PS: Not sure copilot can give 100% response to the Chinese comments.


With Copilot, as it’s called, you still have to do the real work, but it could be a good assist tool in the future.


Feel free to point out any shortcomings in this article in the comments section.

Welcome to collect, like and ask questions. Keep an eye on top water cooler managers and sometimes do more than just boil hot water.