Calculates a Karnaugh map (K-map) for a boolean expression. It supports 2, 3, or 4 variables and returns a 2D array representing the K-map with cells as 0 or 1.

// For a 3-variable expression
const kmap = Chalkboard.bool.Karnaugh("x & !y | z", ["x", "y", "z"]);
  • Parameters

    • input: string

      The boolean expression to map

    • variables: string[]

      An array of variable names (order matters)

    Returns (boolean | 0 | 1)[][]