*Professeur* Caplan reports that ChatGPT, the new artificial intelligence that is all the rage, can pass his economics midterm and get an A.

What about computer science ? I submitted to GPT one problem I offer my students…

Write a Java program that calculates the sum of numbers from 1 to 10,000 (including 1 and 10,000) but omitting numbers that are divisible by three and also omitting numbers whose hundredth digit is 2 or 3 (e.g. 1201 or 3313).

Bing/GPT solves the problem with ease:

public class SumOfNumbers { public static void main(String[] args) { int sum = 0; for (int i = 1; i <= 10000; i++) { if (i % 3 != 0 && (i / 100) % 10 != 2 && (i / 100) % 10 != 3) { sum += i; } } System.out.println("The sum of numbers from 1 to 10,000 (including 1 and 10,000) but omitting numbers that are divisible by three and also omitting numbers whose hundredth digit is 2 or 3 is: " + sum); } }

Maybe it somehow knew just this particular answer. What if I tweak the question a bit?

Write a Java program that calculates the sum of numbers from 1 to 10,000 (including 1 and 10,000) but omitting numbers where the hundredth digit is divisible by 3.

Bing/GPT gets it almost correct:

public class SumOfNumbers { public static void main(String[] args) { int sum = 0; for (int i = 1; i <= 10000; i++) { if ((i / 100) % 3 != 0) { sum += i; } } System.out.println("The sum of numbers from 1 to 10,000 (including 1 and 10,000) but omitting numbers where the hundredth digit is divisible by 3 is: " + sum); } }

What about other questions I often ask… such as…

Write a Java function which can invert the elements in an array of integers.

Bing/GPT gets it right, complete with a detailed explanation…

public static void invertArray(int[] arr) { int n = arr.length; for (int i = 0; i < n / 2; i++) { int temp = arr[i]; arr[i] = arr[n - i - 1]; arr[n - i - 1] = temp; } }

What about database work? Here is a basic question I ask…

What can you say about the attributes A and B if A→B and B→A?

Bing/GPT tells me that…

*If A→B and B→A, then A and B are said to be functionally dependent on each other. This means that the value of A uniquely determines the value of B, and vice versa. In other words, if you know the value of A, you can determine the value of B, and if you know the value of B, you can determine the value of A*

This is correct.

What about a more technical database question ?

Bing/GPT answers…

SELECT COUNT(*) FROM table_name WHERE A = B

Unfortunately, it extends to the exams themselves. Bing/GPT gets much of it right. In the current “introduction to programming” exam, there was only one question the GPT got obviously wrong, but I would have attributed some points ‘for effort’.

Bing/GPT can pass my introductory computer science courses.

I further asked it to solve a problem using the C++ simdjson library. We are definitively well beyond introductory courses. GPT did well enough as the answer is almost correct:

Then I asked it produce its own SIMD routine in C++ to count the number of characters equal to ‘.’ and it did so… It is almost correct…