black box challenge

$ a function guessing game

01.

Overview

The Black Box Challenge is a terminal-based coding game where users attempt to reverse-engineer mystery functions. Players test the function with different inputs, observe outputs, and write code to replicate its behavior using a custom programming language and interpreter.

Technologies Used

  • Language: Custom implementation with lexer and parser
  • UI: Terminal.Gui library for terminal interface
  • Patterns: Abstract Syntax Trees, Visitor Pattern
  • Algorithms: Recursive descent parsing, tree traversal
02.

The Product

The final product is a complete interpreter and interactive coding challenge system built from scratch.

The system features a custom programming language with support for arithmetic, logical, and bitwise operations, variable assignment, and multi-statement programs. The interpreter uses abstract syntax trees and the visitor pattern for clean code organization.

Key features include a terminal-based UI with live code editing, parameter testing table showing expected vs. actual outputs, real-time syntax error reporting, and support for custom mystery functions loaded from files.

Black Box Challenge Screenshot
03.

Takeaways

This project provided deep insights into compiler design and language implementation. Building a complete interpreter from lexer to evaluator illuminated how programming languages work under the hood and the importance of good patterns.

Some key takeaways include:

  • Implementing lexers and parsers using formal grammars and BNF notation
  • Applying the visitor pattern to separate operations from data structures
  • Building and traversing abstract syntax trees for code evaluation
  • Managing operator precedence and associativity in expression parsing
  • Creating interactive terminal applications with the Terminal.Gui library