Array integer median
array-integer-median · version 1.0.0 · Numbers & math · free, no key needed
Select lower and upper middle canonical integers; emit median only for odd length.
Use when you need to: array integer median · median of integer strings · middle values of an integer list.
Supported
- array integer median
- median of integer strings
- middle values of an integer list
Not supported
- average even-length arrays
- floating-point median
- percentiles
- CSV column median
Behavior
- values is a non-empty array of at most 10000 canonical integer strings (BigInt; -0 becomes 0).
- Values are sorted by numeric order ascending; equal values keep their original index order.
- n is the input length as a JSON integer.
- For odd n, lower, upper, and median are the sorted element at 0-based index (n-1)/2.
- For even n, lower is sorted[n/2 - 1], upper is sorted[n/2], and the median key is omitted (no averaging).
- lower, upper, and median (when present) are canonical integer strings.
Input
values(array of string, required): min items 1; max items 10000; each min length 1; each max length 1001
Output
n(integer, required): min 1; max 10000lower(string, required): pattern^(0|-?[1-9][0-9]*)$upper(string, required): pattern^(0|-?[1-9][0-9]*)$median(string, optional): pattern^(0|-?[1-9][0-9]*)$
Limits
- max values: 10000
- max digits: 1000
Example
Request input:
{
"values": [
"9",
"-1",
"4"
]
}
Response:
{
"result": {
"n": 3,
"lower": "4",
"upper": "4",
"median": "4"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "array-integer-median",
"version": "1.0.0",
"input": {
"values": [
"9",
"-1",
"4"
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/array-integer-median/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"values":["9","-1","4"]}'
The machine-readable contract is at /v1/tools/array-integer-median/versions/1.0.0.
CLI
node cli.mjs run array-integer-median 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Array integer GCD: Compute the non-negative greatest common divisor of an array of canonical integer strings.
- Array integer LCM: Compute the non-negative least common multiple of an array of canonical integer strings.
- Array integer cumulative sum: Replace an array of canonical integer strings with equal-length prefix sums.
- Array integer mode: Return the most frequent canonical integers, listing every mode in first-seen order.
- Array integer product: Multiply an array of canonical integer strings and return the canonical product.
- Array rational sum: Sum an array of canonical rationals and return the reduced total.