Extend an Expense Rules Engine with Nested Boolean Conditions
RipplingSoftware Engineer · Technical ScreenLast updated
Extend an expense rules engine with validated AND/OR/NOT expression trees, typed leaf operators, explicit missing-field semantics, and explainable evaluation.
Extend an expense rules engine to support nested AND, OR, and NOT conditions. Explain how you would represent, validate, and evaluate expressions such as:
- restaurant AND meals AND amount greater than 50;
- (entertainment AND amount greater than 100) OR client-hosting;
- amount greater than 100 AND NOT vendor-name equals a specified supplier.
Constraints & Assumptions
The source makes composite rules a discussion extension. Treat the examples as predicates over expense fields and define which field each business term refers to. Rules arrive as data through an API; never evaluate them as arbitrary code.
Clarifying Questions
Which fields and operators are supported? How are missing fields handled? Is an empty AND or OR valid? What limits apply to tree depth and rule size? Do composites filter individual expenses before group aggregation?
Follow-up questions
- How would short-circuiting affect explanation output? How do you introduce a new operator safely? What tests distinguish NOT of a compound expression from negating each child separately?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.