Objective

Learning to program takes frequent practice with exercises that fit a student's level. Instructors rarely have time to write enough good exercises for every student, and sites such as LeetCode are often too hard for people who have never coded. The authors note that earlier AI work on programming mostly gave feedback on code students had already written. Little work had looked at making new exercises on demand.

This paper presents ExGen, a plugin for Visual Studio Code, a program many people use to write code. A student asks it for a new exercise at a chosen difficulty (easy, intermediate or hard). It sends a request to a large language model (an AI trained on huge amounts of text and code), such as OpenAI's GPT models, and then checks the results automatically.

The authors define a ready-to-use exercise as one with three things: a clear problem statement, a working solution with correct test cases, and the difficulty level that was asked for. They asked five questions:

  1. Which prompting strategy gives the best share of ready-to-use exercises?
  2. How well does ExGen's automatic filtering work?
  3. Do different types of keywords change the results?
  4. Do different types of example exercises change the results?
  5. How does the newer, more expensive GPT-4 Turbo compare with the cheaper GPT-3.5 Turbo?

Methods

This is a technical evaluation of a software tool. It is not a classroom study, and no students used the exercises. The question it answers is how often the AI produces a usable exercise, not whether students learn from it.

How ExGen works

The instructor supplies a small set of seed exercises at three difficulty levels. ExGen builds a prompt for the AI in one of two ways. In zero-shot prompting, it only describes the task and the difficulty levels. In few-shot prompting, it also includes one to three example exercises from the student's own collection. Each request asks for 3 exercises at a time, with a keyword such as lists or food and drinks.

ExGen then runs a chain of three filters. First it checks that the solution code compiles. Second, it runs the test cases that came with the exercise. Third, it asks the AI to classify the difficulty, using two examples per level, and keeps the exercise only if the level matches the request.

The experiment

The authors used 59 hand-written seed exercises, split into 28 concept exercises (basic skills such as loops) and 31 domain exercises (real-world problems, such as assigning applicants to rental flats). They tested three keyword types: simple (such as list), complex (such as nested loops) and domain (such as online shopping). They generated 1404 exercises in total, 468 for each difficulty level, with GPT-3.5 Turbo and GPT-4 Turbo (702 for each model). Every exercise was inspected by hand against the three criteria by one experienced instructor, the first author, who has more than 10 years of experience teaching programming. The inspection took about a month. Duplicates were counted once. The authors then measured the share of ready-to-use exercises, the cost and the time per ready-to-use exercise, and how often each filter agreed with the manual check.

Key Findings

Few-shot prompting beat zero-shot prompting, easy exercises were far more likely to be usable than hard ones, and the filters helped. Because the results come from one tool and one inspector, they describe how the tool performed in this test.

Prompting strategies (GPT-3.5 Turbo)

  • Easy exercises: 51.3% were ready-to-use with few-shot prompting, against 32.9% with zero-shot.
  • Intermediate exercises: 20.9% with few-shot and 19.6% with zero-shot.
  • Hard exercises: 13.7% with few-shot and 12.4% with zero-shot.
  • Zero-shot prompting often returned trivial exercises, such as making a list of numbers, and often gave duplicates, with 2 or even 3 of the 3 exercises identical in quite a number of cases.
  • Cost per ready-to-use easy exercise was $0.0046 with few-shot and $0.0064 with zero-shot. Time was about 5 seconds for both. A hard exercise took 15.6 seconds with few-shot and 18.6 seconds with zero-shot.

Filtering

  • Unit tests alone matched the manual check for 81.6% of easy few-shot exercises, but only 54.7% for intermediate and 56.4% for hard ones, because many exercises worked but were at the wrong difficulty.
  • The full chain with few-shot prompting agreed with the manual check 82.9% of the time for easy, 85.5% for intermediate and 91.5% for hard exercises.

Keywords and examples

  • Simple keywords worked across all levels. Complex keywords worked well for intermediate and hard exercises but not for easy ones. Domain keywords gave interesting exercises that were mostly too easy, so they suited easy exercises best and cost more time and money for harder ones.
  • Domain examples did better for easy exercises and concept examples did better for intermediate ones. The type of example mattered less than the type of keyword.

GPT-4 Turbo versus GPT-3.5 Turbo

  • With GPT-4 Turbo, few-shot accuracy was 45.3% for easy, 37.2% for intermediate and 29.1% for hard exercises.
  • It was lower than GPT-3.5 Turbo for easy exercises (45.3% against 51.3%), because it tended to write harder ones.
  • A hard exercise cost $0.1682 with few-shot on GPT-4 Turbo, against $0.0156 on GPT-3.5 Turbo, and took 23.4 seconds against 15.6. The authors say GPT-4 Turbo cost 20 times as much.

Implications

The study tested a tool, so the points below are the authors' views of how to use it and our own cautious reading.

Instructors

  • The authors say instructors need only provide a limited number of seed exercises at each difficulty, and ExGen can then give each student more practice on demand.
  • They suggest that students can also choose to skip filters and get faster results, then check or edit the exercise themselves.
  • The authors note that some hard exercises that failed could be fixed with a few manual changes.
  • Our reading (not the authors' recommendation): until the quality of hard exercises is higher, an instructor may want to look over intermediate and hard exercises before assigning them.

Students

  • Our reading (not the authors' recommendation): students who generate their own exercises should be ready for some to be wrong or too easy, especially at the hard level, and should check with the test cases and with their instructor.

Developers and researchers

  • The authors say that few-shot prompting and a chain of filters gave the best results, so this combination is the default in ExGen.
  • They say simple keywords are the most versatile, while complex keywords suit harder exercises and domain keywords suit easy ones.
  • They conclude that if cost matters, GPT-3.5 Turbo remains useful because it is quick and inexpensive. If hard exercises are needed and cost is not a concern, GPT-4 Turbo can be used.

The evidence is too thin to say whether using ExGen helps students learn, since no learning outcomes were measured.

Limitations

The authors name three threats to the results. AI output can differ from one request to the next. A single human inspector judged each exercise, which can be subjective, especially for difficulty. They tried to limit this by generating more than 1400 exercises and by checking each one in several rounds against existing course exercises. They also note that newer models, such as GPT-4o, may give different results.

The paper does not mention, but no students used the exercises, so there is no evidence about whether they learn from them, find them clear or enjoy them.

The paper does not mention, but the same person who built the tool also did the manual inspection, since the first author was the inspector. A second inspector would make the labels more trustworthy.

The paper does not mention, but the work covers one language (Python) and one introductory course at one university, so results may not apply to other languages or courses.

The paper does not mention, but the study gives no statistical tests for the differences between strategies, so small gaps, such as 20.9% against 19.6% for intermediate exercises, may not mean much.

The paper does not mention, but costs and speeds depend on the OpenAI prices and model versions at the time of the experiments, and these change.

Future Directions

The authors give one clear next step: they plan to continue their research into programming exercise generation with the latest models as they become available. They mention newer models such as GPT-4o as a reason to repeat the tests.

The results also leave several questions open:

  • Can the share of ready-to-use intermediate and hard exercises be raised well above 20.9% and 13.7% with GPT-3.5 Turbo, or without the extra cost of GPT-4 Turbo?
  • Do students who practice with ExGen exercises learn more than those who use exercises from sites such as LeetCode or exercises written by instructors?
  • Would a second human inspector agree with the labels given by the first author?
  • Do the same results hold for other programming languages and for courses beyond the first year?

The bottom line: In this test of the ExGen tool, GPT models wrote usable Python practice exercises about half the time at the easy level, but only 20.9% of intermediate and 13.7% of hard ones with GPT-3.5 Turbo. Few-shot prompting and the chain of filters helped, and GPT-4 Turbo did better on harder exercises at about 20 times the cost. The study used one human inspector and no students, so it shows what the tool can produce, not whether it helps people learn. Instructors could treat the output as a starting point and check it before use.