Can Github Copilot beat the hardest coding questions from Google?

Copilot launched by GitHub a few months back has been of a lot of use for me, recently a thought crossed my mind that made me wonder if Github can beat the hardest of the hardest interview questions.

Backstory

Long story short, I have access to GitHub copilot and I like to do crazy stuff with it, I have asked it to create a lot of things, and most of the time, it works but sometimes it just breaks.

The question

I, as anyone doing this, would do, googled “Hardest Coding Interviews” and found a lot of interesting results.

What I chose:

I found this page to be the best, I decided to read each question and choose the hardest one.

The final questions:

Theory-Based:

  1. In Python, What Is A Generator?

Code-Based:

  1. A Square Matrix Of Size N² And Random Entries From 0 … N², Find The Longest Sequence Of Consecutive Neighbors (I.E. Top, Left, Bottom, Right Entries)
  2. Given An 8x8 Chessboard, Write A Function To Determine How Many Moves It Would Take For A Bishop To Go From A Start Location To An End Location. Then Write A Function To Determine How Spaces It Would Move

Showtime

Theory-Based:

  1. In Python, What is A generator:

Copilot says:

A generator is a function that returns an object (iterator) that you can iterate over (one value at a time),A generator is a function that returns an iterator.

Google Says:

Python provides a generator to create your own iterator function. A generator is a special type of function which does not return a single value, instead, it returns an iterator object with a sequence of values. In a generator function, a yield statement is used rather than a return statement

👏 Both are the same, it’s just that the explanation Google gave is more detailed than the Copilot, which gave a concise explanation.

Code-Based:

  1. A Square Matrix Of Size N² And Random Entries From 0 … N², Find The Longest Sequence Of Consecutive Neighbors (I.E. Top, Left, Bottom, Right Entries)

Copilot says:

Let us test and see if this code works.

I am going to enter 2 as the size of matrix and 1,2,3,4 as the numbers when prompted.

👏 This is correct, the Github copilot did it again!

2. Given An 8x8 Chessboard, Write A Function To Determine How Many Moves It Would Take For A Bishop To Go From A Start Location To An End Location. Then Write A Function To Determine How Spaces It Would Move

Copilot Says:

Let us run and see if it works, I am going to run the functions with the start point being [1,1] and endpoint being [7,7], let us see what happens!

I will log the response and show what is the output

I am not a chess player/expert, so I do not know at all if this is correct or not. I think copilot didn’t really understand what we meant and just created a function that does the latter part of the question i.e “Then Write A Function To Determine How Spaces It Would Move” and not the primary.

So I will leave this up to you to decide, did GitHub copilot do it or not?

Conclusion

So there you have it, Github (almost) beat the hardest coding interview tasks!

My Discord server
My email address
Donate me

A self-learning Developer who is always eager to make more projects/articles to help other users. You will find articles related to different languages here.