Rippling | Algorithm Coding Test | Phonescreen | LLD
Anonymous User
4404

Corporate Credit Card Rules Engine

We plan to offer a corporate credit card to companies that employees can use for business expenses.

Managers can set policies on the cards so that employees do not misuse the card or exceed allowances.

We’re going to be building the rules engine that supports this product.
You are encouraged to ask product-oriented questions and to share your assumptions.

⸻

Initial Rules

We will start with some very basic rules:
• No expense at a restaurant can exceed 75
(vendor_type == "restaurant")
• No airfare expenses
(expense_type == "airfare")
• No entertainment expenses
(expense_type == "entertainment")
• No individual expense over $250
• A trip cannot exceed 2000 in total expenses
• Total meal expenses cannot exceed 200 per trip

⸻ expense

{
    {"expense_id", "001"},
    {"trip_id", "001"},
    {"amount_usd", "49.99"},
    {"expense_type", "client_hosting"},
    {"vendor_type", "restaurant"},
    {"vendor_name", "Outback Roadhouse"},
},

⸻

Problem Statement

Let’s design a system that can handle these rules and flag expenses and trips that violate them.

Implement the following function:

evaluateRules(rules: list, expenses: list) -> ???

•	Expenses will be provided as a list of hashmap/dictionary objects
•	Keys and values are of type string
•	The return type of evaluateRules is up to you

In the future, we will:
• Add more types of rules
• Allow rule creation via an API

So please consider flexibility and extensibility in your design.

Before you get started coding, let’s discuss the return type of the function.

⸻

Types of Rules
1. Ban rules
• Based on expense_type, vendor_type, or vendor_name
2. Maximum amount rule
• Per individual expense
3. Trip total limit rule
• Sum of expenses for a trip cannot exceed a certain amount
4. Expense type aggregation rule
• Sum of expenses for a specific expense_type cannot exceed a certain amount
5. Vendor type limit rule
• Expense at a single vendor_type cannot exceed a certain amount

Comments (5)