Krish Shah Computer Science · Guelph

Case study 03 / 03Collaboration · Machine learning2026

DiscreteSolver

Type a combinatorics word problem; get the operation, the formula and the answer.

Year
2026
Type
Collaboration · Machine learning
Links
DiscreteSolver result: classified as Combinations with n = 10 and r = 3, the formula n! over r!(n − r)!, and 10 choose 3 = 120.
Fig. 01“A committee of 3 from 10 people” → Combinations → 120.

01The problem

Combinatorics word problems are easy to misread: the difference between a permutation and a combination is often one word. DiscreteSolver classifies the question first, then shows the formula it used, so the answer can be checked.

02How it works

  1. 01AskPlain-English question
  2. 02ClassifyTF-IDF + linear SVM
  3. 03Extractn and r by regex
  4. 04SolveFormula
  5. 05ShowRendered with KaTeX

A small Flask app. The operation is decided before any numbers are read: the classifier picks it from the wording, a parser then pulls out n and r, and the formula is shown next to the answer — so a misread question shows up in the working instead of hiding behind a number.

03What it does

  1. 01
    Classify

    A TF-IDF and linear support-vector classifier, trained on a labelled set of word problems, picks one of six operations.

  2. 02
    Extract

    A regex parser pulls out n and r, including number words like “five”.

  3. 03
    Show the working

    The result is rendered with KaTeX: operation, formula and value.

04Built with

  • Python
  • Flask
  • scikit-learn
  • pytest
  • KaTeX
  • Docker