Game Theory
Stars and bars API
Counts the ways to distribute identical items into distinct bins (with or without empty bins) via the stars-and-bars formula. Answers 'How many ways to split 10 identical balls into 4 boxes?', 'Non-negative integer solutions to x1+...+x4=10?'.
Price$0.04per request
MethodPOST
Route/v1/gametheory/stars-and-bars
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
combinatoricsstars-and-barscompositionsdistributionscountingballs-in-boxesdiscreteinteger-solutions
API URL
Integration docshttps://x402.hexl.dev/v1/gametheory/stars-and-barsExample request
{
"items": 10,
"bins": 4,
"allowEmpty": true
}Example response
{
"items": 10,
"bins": 4,
"allowEmpty": true,
"ways": 286,
"waysExact": "286",
"isExactInteger": true,
"formula": "C(10 + 4 - 1, 4 - 1)",
"interpretation": "Number of ways to distribute 10 identical items into 4 distinct bins (empty bins allowed): 286."
}Input schema
{
"type": "object",
"required": [
"items",
"bins"
],
"properties": {
"items": {
"type": "integer",
"minimum": 0,
"examples": [
10
]
},
"bins": {
"type": "integer",
"minimum": 1,
"examples": [
4
]
},
"allowEmpty": {
"type": "boolean",
"examples": [
true
]
}
}
}Output schema
{
"type": "object",
"additionalProperties": true
}