I recently got access to [Github's Copilot](https://copilot.github.com/) and it struck me that it could generate a lot of algorithms that someone might not know or even solve some of the simpler problems with ease. Despite this technology being very new, I think it's worth adding a rule restricting or prohibiting the use of certain AI code completers. From what I'm seeing in the development of this field, it's only a matter of years before someone trains an AI that can perform in coding contests at a LGM level. ↵
↵
Edit: To clarify, I don't believe it will be Copilot that will be trained at this level. LGM is an exaggeration but it's certainly possible for a Master level AI because of how much the easier problems are somewhat pattern recognition.↵
↵
↵
↵
Examples to demonstrate the power of Copilot:↵
---------------------------------------------↵
↵
<spoiler summary="1. Finding Maximum Subarray">↵
↵
What was given:↵
↵
~~~~~↵
nums = [6, 7, -2, 4, -4, 6, 12, 5]↵
↵
# find max subarray↵
~~~~~↵
↵
What was generated:↵
↵
~~~~~↵
max_sum = float('-inf')↵
current_sum = 0↵
for i in range(len(nums)):↵
current_sum += nums[i]↵
if current_sum > max_sum:↵
max_sum = current_sum↵
if current_sum < 0:↵
current_sum = 0↵
↵
print(max_sum)↵
~~~~~↵
↵
</spoiler>↵
↵
↵
<spoiler summary="2. Find 2 elements in an array that equal to N">↵
What was given:↵
↵
~~~~~↵
nums = [6, 7, -2, 4, -4, 6, 12, 5]↵
↵
# Find a pair of numbers that sum to n.↵
~~~~~↵
↵
What was generated (1st solution):↵
↵
~~~~~↵
def pair_sum(nums, n):↵
seen = set()↵
output = set()↵
for num in nums:↵
target = n — num↵
if target not in seen:↵
seen.add(num)↵
else:↵
output.add((min(num, target), max(num, target)))↵
return len(output)↵
↵
~~~~~↵
↵
Second Solution (brute force)↵
↵
~~~~~↵
def find_pair(nums, n):↵
for i in range(len(nums)):↵
for j in range(i + 1, len(nums)):↵
if nums[i] + nums[j] == n:↵
return nums[i], nums[j]↵
return None↵
~~~~~↵
↵
</spoiler>↵
↵
↵
↵
<spoiler summary="3. Coin Change">↵
What was given↵
↵
~~~~~↵
coins = [1, 2, 4, 5, 9, 69, 420]↵
↵
# minimum number of coins needed to make n cents↵
# dynamic programming↵
~~~~~↵
↵
What was generated (1st Solution)↵
↵
~~~~~↵
def minCoins(n):↵
if n < 0:↵
return 0↵
elif n in coins:↵
return 1↵
else:↵
return 1 + min(minCoins(n-i) for i in coins if i <= n)↵
↵
~~~~~↵
↵
What was generated (4th Solution) (Rest are garbage code)↵
↵
~~~~~↵
↵
def min_coins(n):↵
table = [0] + [10000] * n↵
for i in range(1, n + 1):↵
for j in coins:↵
if i >= j and table[i - j] + 1 < table[i]:↵
table[i] = table[i - j] + 1↵
return table[n]↵
~~~~~↵
↵
</spoiler>↵
↵
↵
↵
I couldn't really make it write out many advanced algorithms but this is for sure going to change in the future. So far I find it's the best with very simple trivial functions (check if number is a power of 2, convert string to integer, check for duplicates, find minimum etc.)↵
↵
Personally, I'll be coding without copilot in competitive programming because I believe this to just be another form of cheating and doesn't help me get better. Regardless, I want to hear what the community thinks on this matter and if it should be banned or not. ↵
↵
↵
↵
Edit: To clarify, I don't believe it will be Copilot that will be trained at this level. LGM is an exaggeration but it's certainly possible for a Master level AI because of how much the easier problems are somewhat pattern recognition.↵
↵
↵
↵
Examples to demonstrate the power of Copilot:↵
---------------------------------------------↵
↵
<spoiler summary="1. Finding Maximum Subarray">↵
↵
What was given:↵
↵
~~~~~↵
nums = [6, 7, -2, 4, -4, 6, 12, 5]↵
↵
# find max subarray↵
~~~~~↵
↵
What was generated:↵
↵
~~~~~↵
max_sum = float('-inf')↵
current_sum = 0↵
for i in range(len(nums)):↵
current_sum += nums[i]↵
if current_sum > max_sum:↵
max_sum = current_sum↵
if current_sum < 0:↵
current_sum = 0↵
↵
print(max_sum)↵
~~~~~↵
↵
</spoiler>↵
↵
↵
<spoiler summary="2. Find 2 elements in an array that equal to N">↵
What was given:↵
↵
~~~~~↵
nums = [6, 7, -2, 4, -4, 6, 12, 5]↵
↵
# Find a pair of numbers that sum to n.↵
~~~~~↵
↵
What was generated (1st solution):↵
↵
~~~~~↵
def pair_sum(nums, n):↵
seen = set()↵
output = set()↵
for num in nums:↵
target = n — num↵
if target not in seen:↵
seen.add(num)↵
else:↵
output.add((min(num, target), max(num, target)))↵
return len(output)↵
↵
~~~~~↵
↵
Second Solution (brute force)↵
↵
~~~~~↵
def find_pair(nums, n):↵
for i in range(len(nums)):↵
for j in range(i + 1, len(nums)):↵
if nums[i] + nums[j] == n:↵
return nums[i], nums[j]↵
return None↵
~~~~~↵
↵
</spoiler>↵
↵
↵
↵
<spoiler summary="3. Coin Change">↵
What was given↵
↵
~~~~~↵
coins = [1, 2, 4, 5, 9, 69, 420]↵
↵
# minimum number of coins needed to make n cents↵
# dynamic programming↵
~~~~~↵
↵
What was generated (1st Solution)↵
↵
~~~~~↵
def minCoins(n):↵
if n < 0:↵
return 0↵
elif n in coins:↵
return 1↵
else:↵
return 1 + min(minCoins(n-i) for i in coins if i <= n)↵
↵
~~~~~↵
↵
What was generated (4th Solution) (Rest are garbage code)↵
↵
~~~~~↵
↵
def min_coins(n):↵
table = [0] + [10000] * n↵
for i in range(1, n + 1):↵
for j in coins:↵
if i >= j and table[i - j] + 1 < table[i]:↵
table[i] = table[i - j] + 1↵
return table[n]↵
~~~~~↵
↵
</spoiler>↵
↵
↵
↵
I couldn't really make it write out many advanced algorithms but this is for sure going to change in the future. So far I find it's the best with very simple trivial functions (check if number is a power of 2, convert string to integer, check for duplicates, find minimum etc.)↵
↵
Personally, I'll be coding without copilot in competitive programming because I believe this to just be another form of cheating and doesn't help me get better. Regardless, I want to hear what the community thinks on this matter and if it should be banned or not. ↵
↵
↵